This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# not actually tested | |
from gevent.queue import Queue | |
from gevent.pool import Pool | |
class GreenPile(object): | |
def __init__(self, size_or_pool=1000): | |
if isinstance(size_or_pool, Pool): | |
self.pool = size_or_pool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### traceback | |
Traceback (most recent call last): | |
File "/Users/newshour/code/python/chatterbox/lib/python2.6/site-packages/gevent/greenlet.py", line 405, in run | |
result = self._run(*self.args, **self.kwargs) | |
File "/Users/newshour/code/python/chatterbox/lib/python2.6/site-packages/pymongo/collection.py", line 270, in insert | |
check_keys, safe, kwargs), safe) | |
File "/Users/newshour/code/python/chatterbox/lib/python2.6/site-packages/pymongo/connection.py", line 601, in _send_message | |
sock = self.__pool.socket() | |
File "/Users/newshour/code/python/chatterbox/lib/python2.6/site-packages/pymongo/connection.py", line 147, in socket |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import signal | |
import gevent | |
from gevent import get_hub | |
import traceback | |
def alarm_handler(*args): | |
signal.alarm(1) | |
if gevent.getcurrent() is not get_hub(): | |
get_hub().loop.update_now() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Class for managing multiple servers or anything with start() and stop() methods | |
class ServerRack(object): | |
def __init__(self, servers): | |
self.servers = servers | |
def start(self): | |
started = [] | |
try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cdef class A: | |
cdef object member | |
#ifdef _WIN32 | |
cdef object windows_only_member | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gevent.pywsgi | |
from websocket import WebSocketUpgrader | |
class UpgradableWSGIHandler(gevent.pywsgi.WSGIHandler): | |
def handle_one_response(self): | |
connection_header = self.environ.get('HTTP_CONNECTION', '').lower() | |
if connection_header == 'upgrade' and self.server.upgrade_handler: | |
upgrade_header = self.environ.get('HTTP_UPGRADE', '').lower() | |
handler = self.server.upgrade_handler(upgrade_header, self.environ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while not process_shutdown: # only process if process_shutdown has not be signalled yet | |
with process_shutdown: | |
# means Interrupt will be raised here asynchronously | |
x = do_something() | |
# in some other greenlet: | |
process_shutdown.signal() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from gevent import server | |
from gevent.baseserver import _tcp_listener | |
from gevent.monkey import patch_all; patch_all() | |
from multiprocessing import Process, current_process, cpu_count | |
def note(format, *args): | |
sys.stderr.write('[%s]\t%s\n' % (current_process().name, format%args)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* gcc -DEV_STANDALONE=1 testsigchld4.c -o testsigchld4 | |
* | |
* Expected output: infinite sequence of "*." | |
* | |
* Actual output: | |
* denis@denis-laptop:~/work/libev-cvs$ ./testsigchld4 | |
* Alarm clock | |
* (and the subprocess exits 60 seconds later). | |
* | |
* */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* gcc -DEV_STANDALONE=1 testsigchld5.c -o testsigchld5 | |
* | |
* Expected output: infinite sequence of "*." | |
* | |
* Actual output: | |
* denis@denis-laptop:~/work/libev-cvs$ ./testsigchld4 | |
* Alarm clock | |
* (and the subprocess exits 60 seconds later). | |
* | |
* */ |
OlderNewer