M
M
Maxim2016-10-08 15:57:17
Django
Maxim, 2016-10-08 15:57:17

How to copy an object for further use?

Hello!
Have a function

@csrf_exempt
def tw(request):
    if request.method == 'GET':
        auth = tweepy.OAuthHandler(consumer_key, consumer_secret, callback_url)
        return redirect(auth.get_authorization_url())

which does some manipulation and creates an object at the address
<tweepy.auth.OAuthHandler object at 0x7f0de94f2a20>

I need to use it in another function, such as this plan
auth.get_access_token(tw_verifier)
. How to get exactly the object that was formed in the first function?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2016-10-08
@maximkv25

Store it in memory, like a cache. If there is a reachable link to it, you can get it and GC will not crash it. If there are several workers (and it usually is), then the cache must be used external. For example, Redis or memcached. Here you will need pickle to pack the object.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question