Questions tagged [gevent]

Gevent is a coroutine-based Python networking library that uses greenlet to provide a high-level synchronous API on top of libevent (libev after 1.0) event loop.

Gevent is a coroutine-based Python networking library that uses greenlet to provide a high-level synchronous API on top of libevent (libev after 1.0) event loop.

1147 questions
16
votes
1 answer

Is it safe to use SQLalchemy with gevent?

I know that some database drivers and other libraries providing connection to external services are incompatible with coroutine-based network libraries. However, I couldn't find out if SQLAlchemy can be safely used with such libraries (namely,…
dpq
  • 9,028
  • 10
  • 49
  • 69
16
votes
1 answer

When to use Threadpool in Gevent

I've noticed that Gevent has threadpool object. Can someone explain to me when to use threadpool and when to use regular pool? Whats the difference between gevent.threadpool and gevent.pool?
Goranek
  • 826
  • 1
  • 10
  • 23
16
votes
2 answers

Which features are monkey patched by gunicorn gevent worker?

I am using gunicorn to run some flask and django applications, using the gevent worker, and have some questions... First, I assume that because gunicorn fork and instantiate my processes, it will monkey patch the standard modules, and i do not have…
Joseph
  • 3,085
  • 3
  • 23
  • 33
15
votes
3 answers

Greenlet runtime error and deployed app in docker keeps booting all the workers

RuntimeWarning: greenlet.greenlet size changed, may indicate binary incompatibility. Expected 144 from C header, got 152 from PyObject And all the workers are being booted. 2020-09-28T14:09:41.864089908Z [2020-09-28 14:09:41 +0000] [31]…
Vaibhav
  • 507
  • 2
  • 4
  • 20
15
votes
4 answers

How do I detect if Gevent's monkey-patching is active?

I have a Python unittest that depends on multiprocessing and therefore must not run when Gevent's monkey-patching is active. Is there a Python statement that can tell me whether gevent.monkey.patch_all has run or not?
A. Jesse Jiryu Davis
  • 23,641
  • 4
  • 57
  • 70
15
votes
2 answers

In a gevent application, how can I kill all greenlets that have been started?

I have a gevent application that spawns multiple greenlets across multiple modules. I want to be able to gracefully shutdown the application (either internally or by catching SIGTERM, for instance), allowing greenlets to terminate nicely by catching…
squirrel
  • 5,114
  • 4
  • 31
  • 43
15
votes
2 answers

Differences between gevent and tornado

I understand that both tornado and gevent are asynchronous python frameworks. While reading the bottle documentation I found that gevent actually is NOT asynchronous, and you can create thousands to pseudo-threads that work synchronously. Seondly,…
treecoder
  • 43,129
  • 22
  • 67
  • 91
14
votes
6 answers

How to install gevent on Windows?

I'm trying to install gevent on Windows. In order to do that, I've downloaded and compiled libevent, then I run pip install gevent and get an error: Please provide path to libevent source with --libevent DIR. How can I pass the libevent option to…
Ivan Gromov
  • 4,195
  • 9
  • 41
  • 57
14
votes
1 answer

Access flask.g inside greenlet

I'm using Flask + gevent and want to access the flask.g application global inside the target function of a greenlet. I'm using the copy_current_request_context decorator and have a situation pretty similar to example given in the docs: import…
jamesdarabi
  • 280
  • 1
  • 3
  • 13
14
votes
2 answers

In gevent, how can I dump stack traces of all running greenlets?

For debugging purposes, I would like to iterate over all greenlets and obtain their trace traces -- how can I do that with gevent? Basically, I would like to do the gevent equivalent of this.
kdt
  • 27,905
  • 33
  • 92
  • 139
14
votes
4 answers

gevent library: "Import Error: no module named greenlet"

hello guys I have downloaded a script that require gevent python library and every time I run the script it says : File "shodan.py", line 7, in from gevent import monkey File "C:\Python27\lib\site-packages\gevent\__init__.py", line 48,…
Reality Returns
  • 180
  • 1
  • 1
  • 8
13
votes
4 answers

Monitoring gevent exceptions in jobs

I'm building an application using gevent. My app is getting rather big now as there are a lot of jobs being spawned and destroyed. Now I've noticed that when one of these jobs crashes my entire application just keeps running (if the exception came…
Stephan
  • 3,679
  • 3
  • 25
  • 42
13
votes
2 answers

pymongo + gevent: throw me a banana and just monkey_patch?

Quickie here that needs more domain expertise on pymongo than I have right now: Are the "right" parts of the pymongo driver written in python for me to call gevent monkey_patch() and successfully alter pymongo's blocking behavior on r/w within…
egbutter
  • 810
  • 11
  • 21
13
votes
1 answer

Running flask + gevent + requests not serving 'concurrently'

I kick off my flask app like this: #!flask/bin/python from app import app_instance from gevent.pywsgi import WSGIServer #returns and instance of the application - using function to wrap configuration app = app_instance() http_server =…
fansonly
  • 1,150
  • 4
  • 14
  • 29
13
votes
1 answer

How to avoid blocking code in python with gevent?

I am playing around with gevent, and I am trying to understand why my code is blocking and how I can fix it. I have a pool of greenlets, and each of them talk to a thrift client which gathers data from a remote thrift server. For the purpose of the…
Martin
  • 905
  • 9
  • 19