sergeyz
sergeyz

Reputation: 1328

gevent.patch_all() and third-party libraries

gevent library documentation suggests to use gevent.monkey.patch_all() function to make standard library modules cooperative.

As I understand this method only works for my code (written by me), because I can explicitly monkey-patch standard library before importing standard library modules.

What about third-party libraries (websocket client for example), which import threading, socket modules internally. Is there a way for this libraries to use patched version of threading and socket modules ?

Upvotes: 0

Views: 332

Answers (1)

David K. Hess
David K. Hess

Reputation: 17246

Monkey patch at the earliest possible moment in your code (i.e. before any of your third party modules have been imported).

Then, when the third party modules are imported, they will use the monkey-patched versions of the standard libraries.

Upvotes: 1

Related Questions