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
0
votes
1 answer

Why python gevent.joinall execute all greenlets

I have the following Python code: >>> import gevent >>> from gevent import monkey; monkey.patch_all() >>> >>> def fooFn(k): ... return 'gevent_'+k ... >>> threads = [] >>> threads.append(gevent.spawn(fooFn,'0')) >>>…
Shod
  • 801
  • 3
  • 12
  • 33
0
votes
2 answers

using pycharm + gevent greenlet.join() no longer blocks

so after the upgrade of gevent to 1.1rc4 (from 1.0.2) while running through pycharm, I can't get greenlets to join properly... take this code for example: from gevent import monkey, Greenlet, hub import gevent hub.Hub.resolver_class =…
Grady Player
  • 14,399
  • 2
  • 48
  • 76
0
votes
0 answers

LoopExit: 'This operation would block forever' with Redis as cache on Django

I work with Django 1.7 python 2.7. In Django I have several functions. One function prepares necessary information and stores it in Redis. After that another function asynchronously starts several times, gets information from the Redis, calculates…
asduj
  • 341
  • 2
  • 10
0
votes
1 answer

explicit switch() with gevent

I have a primitive producer/consumer script running in gevent. It starts a few producer functions that put things into a gevent.queue.Queue, and one consumer function that fetches them out of the queue again: from __future__ import…
Simon
  • 12,018
  • 4
  • 34
  • 39
0
votes
0 answers

use "while true" in gevent(Greenlets), the program will stop gradually

I want to use the greenlets as the thread: def check_all_proxy(): while True: try: r = get_redis() proxy = r.spop(tmp_key) if proxy == None: gevent.sleep(3) …
Bin He
  • 21
  • 2
0
votes
1 answer

Does thread-safe generally imply greenlet-safe in Python?

The situation I have in mind is using a python extension module that can call back into python, so that there may be a mixture of python and non-python stack frames at the point when a greenlet yields. I assume that if a module uses thread-local…
Oliver Goodman
  • 671
  • 6
  • 14
0
votes
1 answer

Greenlet version is too old error even the 0.4.5 is installed. Why?

I get this error, Your version of greenlet (0.3.1) is too old (required >= 0.3.2) when I am trying to run ssbench openstack-swift benchmarking tool. I updated the greenlet to the version 0.4.5 using sudo pip install --upgrade greenlet but it still…
Anayag
  • 145
  • 1
  • 10
0
votes
1 answer

fsm with gevent with its own (infinite) call stack

I was wondering how can I define a finite state machine which has loops using a greenlet in python without causing a stckoverflow. From https://greenlet.readthedocs.org/en/latest/: "A “greenlet” is a small independent pseudo-thread. Think about it…
krish7919
  • 892
  • 2
  • 13
  • 30
0
votes
2 answers

Are greenlets really useful by themselves?

I'm having some trouble conceptualizing what the big deal is with greenlets. I understand how the ability to switch between running functions in the same process could open the door to a world of possibilities; but i haven't come across any examples…
Noob Saibot
  • 4,573
  • 10
  • 36
  • 60
0
votes
1 answer

Too many connections while using gevent socketio

I am getting too many connections (1040) when using gevent socketio. I am using monkey patch right now. Can I limit the number of threads(greenlets) created and make some jobs share the threads? I am using gunicorn and django.
0
votes
1 answer

Getting ServerNotFoundError when using gevent/greenlets with requests

I'm trying to paralellize the retrieval of data from a remote API. The remote API doesn't have any bulk capability, so for each object I need, I have to make a separate GET request. I've added gevent into the mix. It works great sometimes, but if I…
Z Jones
  • 2,015
  • 4
  • 23
  • 42
0
votes
1 answer

Implementing Stackless Python

I really admire the functionality of Stackless Python, and I've been looking around for a way to emulate its syntax while still using the standard Python 3 interpreter. An article by Alex J. Champandard in a gamedev blog made it look as though the…
Humble Penguin
  • 323
  • 1
  • 3
  • 9
0
votes
1 answer

How does a connection pool in MongoDB with pymongo driver?

I'm using mongodb with pymongo driver on gevent based framework. I don't understand working pool connection. I'm creating a new connection instance on every request: connection = MongoClient(host='localhost', port=27017,…
centum
  • 121
  • 1
  • 3
  • 8
0
votes
1 answer

Using `greenlet` as decorator

Would it make sense to use greenlet.greenlet as a decorator, converting a regular function to a greenlet as follows: from greenlet import greenlet @greenlet def f(args): # ... z = g.switch(u) # ... @greenlet def g(args): # ... def…
max
  • 49,282
  • 56
  • 208
  • 355
0
votes
2 answers

gevent pool.wait_available() method meaning

Look, people. We have a question about gevent.pool class and pool.wait_available() method, both code snippets 1. def fetch(url): print 'start fetching...', url data = urllib2.urlopen(url) print url,':',data.code urls =…
Ellochka Cannibal
  • 1,750
  • 2
  • 19
  • 31
1 2 3
9
10