Last active
August 21, 2018 09:46
-
-
Save mickeprag/75a0fbf04cfd06c3fe48b759da22f5ef to your computer and use it in GitHub Desktop.
This file contains 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
from lupa import LuaRuntime | |
script = """ | |
function callDone(response) | |
end | |
function run(arg) | |
http:get(callDone) | |
end | |
""" | |
class Request(object): | |
def get(self, success): | |
return PendingRequest(success) | |
class PendingRequest(object): | |
def __init__(self, callback): | |
super(PendingRequest,self).__init__() | |
self.callback = callback | |
lua = LuaRuntime() | |
lua.globals().http = Request() | |
lua.execute(script) | |
fn = getattr(lua.globals(), 'run') | |
for i in range(10000): | |
print("Start call", i) | |
thread = fn.coroutine() | |
try: | |
thread.send(None) | |
except StopIteration: | |
pass | |
print("Wait for shutdown") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment