Questions tagged [greenlets]

greenlet is a Python C-extension that adds lightweight coroutines to the language, useful for cooperative multitasking.

greenlet is a Python C-extension that adds lightweight coroutines to the language, useful for cooperative multitasking.

150 questions
4
votes
2 answers

Correct greenlet termination

I am using gevent to download some html pages. Some websites are way too slow, some stop serving requests after period of time. That is why I had to limit total time for a group of requests I make. For that I use gevent "Timeout". timeout =…
Termos
  • 664
  • 1
  • 7
  • 31
4
votes
1 answer

Catching exceptions raised in the greenlets

I'm trying to catch the exceptions raised within the greenlets. According to this tutorial, unfortunately 'exceptions raised in the Greenlet, stay inside the Greenlet'. In the code below, I have a sync method which spawns crawl greenlets. Those…
Arman
  • 1,074
  • 3
  • 20
  • 40
4
votes
1 answer

Gevent greenlet bubbling up exceptions to the parent

In using gevent, whenever a child greenlet throws an exception, I would like it to bubble up to the parent (and ideally have the parent throw the exception). In the documentation for greenlets, it says this is automatically done, but this doesn't…
Jon Chu
  • 1,877
  • 2
  • 20
  • 19
3
votes
1 answer

Gevent exceptions in Django when patching Python modules

I have installed the gevent and greenlet libraries and in the __init__.py file of my Djano application I dumped in these two lines: from gevent import monkey monkey.patch_all() Now it's very often I see errors in my Django console that…
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
3
votes
1 answer

AWS can't import Python greenlet module

I created an AWS lambda with Python 3.6, which uses an external library not already in the AWS env. Once deployed with serverless, I call the handler and it gives me the error: START RequestId: 123456 Version: $LATEST Unable to import module…
Barbi
  • 139
  • 1
  • 11
3
votes
1 answer

Flask-SQLAlchemy ERROR: 'No application found. Either work inside a view function or push'

I am in the process of trying to use flask-sqlalchemy, and I have followed numerous examples in the documentation of how to get the Flask application setup. However, I am not able to get the app context for some reason. I am currently using the…
3
votes
1 answer

Gevent blocked by flask even use monkey patch

I'm using the flask+gevent to build my server, but the gevent named 'getall' was blocked by flask, so the 'getall' function cannot print message in this code. The monkey patch is in use. import time import WSGICopyBody from flask import…
vinllen
  • 1,369
  • 2
  • 18
  • 36
3
votes
1 answer

Why do we need gevent.queue?

My understanding of Gevent is that it's merely concurrency and not parallelism. My understanding of concurrency mechanisms like Gevent and AsyncIO is that, nothing in the Python application is ever executing at the same time. The closest you get…
Josh Russo
  • 3,080
  • 2
  • 41
  • 62
3
votes
0 answers

Locust master process gets killed due to out of memory

Having a Locust master and slave setup with 8 slaves running om 8 AWS instances with 4 GB RAM and 64bit Ubuntu. ON setting the number of users to 500 and and hatch rate to 200 i see master process gets killed with-in 15 mins. MIN_WAIT & MAX_WAIT…
santosh
  • 3,947
  • 3
  • 21
  • 32
3
votes
2 answers

Gevent: is it a good practice to yield in each for-loop iteration?

I'm coming from Node.js where libraries such as https://github.com/caolan/async allow to iterate asynchronously through arrays without blocking the event loop. am I correct that achieving the same with Gevent can be done by calling sleep(0) on each…
Gal Ben-Haim
  • 17,433
  • 22
  • 78
  • 131
3
votes
1 answer

What is the difference between 'kill' greenlet block or not

when I am trying to kill a greenlet using kill(), a 'block' param is default by True, Greenlet.kill(self, exception, block, timeout) the doc says: If block is True (the default), wait until the greenlet dies or the optional timeout expires. If…
user1221244
  • 289
  • 4
  • 12
3
votes
1 answer

Why does gevent execute this unjoined greenlet?

Code: import gevent import time def func(a, t): time.sleep(t) print "got here", a gevent.spawn(func, 'a', 4) gevent.spawn(func, 'b', 0).join() time.sleep(3) print "exit" Output: got here a got here b exit Expectation: I never join on the…
ʞɔıu
  • 47,148
  • 35
  • 106
  • 149
3
votes
2 answers

How to use gevent and tornado in a single application?

I'm working on using gevent and tornado inside the same application so that libraries that doesn't support tornado's ioloop can be subdued to use gevent to act asynchronously. I thought I'd need to run two real systems threads, one dedicated to…
Tony
  • 36,591
  • 10
  • 48
  • 83
3
votes
1 answer

Deadlock with PyMongo and gevent

I am using PyMongo and gevent together, from a Django application. In production, it is hosted on Gunicorn. I am creating a single Connection object at startup of my application. I have some background task running continuously and performing a…
Flavien
  • 7,497
  • 10
  • 45
  • 52
2
votes
0 answers

python3.11 + Celery + Gevent -> "returned NULL without setting an exception"

When running celery worker on a container using python3.11 with redis as a broker - I am getting the following exception. Downgrading to python 3.10 solves the problem, but is there another solution? 2023-08-04 11:10:28,805] [WARNING] [Dummy-748]…
DanielM
  • 3,598
  • 5
  • 37
  • 53
1 2
3
9 10