question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v2 Tweet, unable to unpickle using dill, max recursion reached

See original GitHub issue

Using the new v2 twitter API and version 4.5.0 of Tweepy, with version 0.3.4 of dill, the following code results in a RecursionError: maximum recursion depth exceeded:

query = 'your search here'

import tweepy
from twitter_credentials import bearer_token
client = tweepy.Client(bearer_token=bearer_token, return_type = tweepy.Response)

search_result = client.search_recent_tweets(query = query, max_results=10)

t = search_result.data[0]

import dill
serialized = dill.dumps(t)

u = dill.loads(serialized)

The problem seems to be in __getattr__:

  File "/Users/username/opt/anaconda3/lib/python3.8/site-packages/tweepy/mixins.py", line 30, in __getattr__
    return self.data[name]
  [Previous line repeated 992 more times]

It sure would be dandy to be able to serialize using dill!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
michaelmilleryodercommented, Oct 27, 2022

@Harmon758 Setting return_type=dict when I initialize the tweepy Client should work! I didn’t know about that option–thanks.

2reactions
michaelmilleryodercommented, Aug 8, 2022

I also got this error while trying to pickle Response objects. I ended up saving out each part of Response objects (.data, .includes, .errors) as JSON lines files, but it would have saved me time to simply be able to pickle them all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hitting Maximum Recursion Depth Using Pickle / cPickle
Trying to pickle a highly recursive data structure may exceed the maximum recursion depth, a RuntimeError will be raised in this case.
Read more >
tweepy - Bountysource
Using the new v2 twitter API and version 4.5.0 of Tweepy, with version 0.3.4 of dill, the following code results in a RecursionError:...
Read more >
Release Notes — Airflow Documentation
Rewrite recursion when parsing DAG into iteration (#25898) ... A sensor will immediately fail without retrying if timeout is reached.
Read more >
Airflow Documentation - Read the Docs
Airflow is a platform to programmatically author, schedule and monitor workflows. Use airflow to author workflows as directed acyclic graphs ...
Read more >
Node [[@karlicoss/python]] in anagora.org
[2020-05-02] zachwill/moment: Dealing with dates in Python shouldn't have to ... [2019-10-27] pylint exceed maximum recursion depth · Issue #2388 · PyCQA/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found