Skip to content

Instantly share code, notes, and snippets.

@wayslog
Created May 27, 2017 03:46
Show Gist options
  • Save wayslog/86e90dae82e0bb82777af2dabc44ad72 to your computer and use it in GitHub Desktop.
Save wayslog/86e90dae82e0bb82777af2dabc44ad72 to your computer and use it in GitHub Desktop.
import gevent.monkey
gevent.monkey.patch_all()
import time
from multiprocessing import Process
import gevent
import redis
from lanaya.invoker.bind import unwrap_bind
c = redis.StrictRedis()
def greenlet_func():
time.sleep(5)
c.incr('count')
g = gevent.spawn(greenlet_func)
def dummy():
time.sleep(6)
# worker = unwrap_bind(dummy)
# worker.async_apply()
worker = Process(target=dummy)
worker.start()
worker.join()
# worker.complete()
g.join()
@wayslog
Copy link
Author

wayslog commented May 27, 2017

lanaya 是我自己的库,这里没用到,可以直接移除。

@wayslog
Copy link
Author

wayslog commented May 27, 2017

测试 redis 里的最后结果是 2 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment