From a9127c8d7927e7a64e7edf9d15eadbfffc3bb56a Mon Sep 17 00:00:00 2001 From: Unbit Date: Thu, 6 Jun 2013 17:25:03 +0200 Subject: [PATCH] added support for pypy uwsgi.async_sleep --- plugins/pypy/pypy_setup.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/pypy/pypy_setup.py b/plugins/pypy/pypy_setup.py index 096ae4a2..047f90ec 100644 --- a/plugins/pypy/pypy_setup.py +++ b/plugins/pypy/pypy_setup.py @@ -182,6 +182,7 @@ int uwsgi_signal_add_cron(uint8_t, int, int, int, int, int); void uwsgi_alarm_trigger(char *, char *, size_t); void async_schedule_to_req_green(void); +void async_add_timeout(struct wsgi_request *, int); %s @@ -581,13 +582,17 @@ for i in range(0, lib.uwsgi.exported_opts_cnt): else: uwsgi.opt[k] = v +def uwsgi_pypy_current_wsgi_req(): + wsgi_req = lib.uwsgi.current_wsgi_req() + if wsgi_req == ffi.NULL: + raise Exception("unable to get current wsgi_request, check your setup !!!") + return wsgi_req + """ uwsgi.suspend() """ def uwsgi_pypy_suspend(): - wsgi_req = lib.uwsgi.current_wsgi_req(); - if wsgi_req == ffi.NULL: - raise Exception("unable to get current wsgi_request, check your setup !!!") + wsgi_req = uwsgi_pypy_current_wsgi_req() if lib.uwsgi.schedule_to_main: lib.uwsgi.schedule_to_main(wsgi_req); uwsgi.suspend = uwsgi_pypy_suspend @@ -626,6 +631,15 @@ def uwsgi_pypy_workers(): uwsgi.workers = uwsgi_pypy_workers +""" +uwsgi.async_sleep(timeout) +""" +def uwsgi_pypy_async_sleep(timeout): + if timeout > 0: + wsgi_req = uwsgi_pypy_current_wsgi_req(); + lib.async_add_timeout(wsgi_req, timeout); +uwsgi.async_sleep = uwsgi_pypy_async_sleep + print "Initialized PyPy with Python", sys.version print "PyPy Home:", sys.prefix