-
-
Notifications
You must be signed in to change notification settings - Fork 245
WIP - Moving back to threads #681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -95,60 +93,63 @@ def __init__(self, interp=None, request_refresh=lambda: None): | |||
""" | |||
self.interp = interp or code.InteractiveInterpreter() | |||
self.source = None | |||
self.main_context = greenlet.getcurrent() | |||
self.code_context = None | |||
self.code_thread = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.request_refresh = request_refresh | ||
# waiting for response from main thread | ||
self.code_is_waiting = False | ||
# sigint happened while in main thread | ||
self.sigint_happened_in_main_context = False | ||
self.sigint_happened_in_main_context = False # TODO rename context to thread |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
|
||
def load_code(self, source): | ||
"""Prep code to be run""" | ||
assert self.source is None, "you shouldn't load code when some is " \ | ||
"already running" | ||
self.source = source | ||
self.code_context = None | ||
self.code_thread = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above. This is just noise.
|
||
def _unload_code(self): | ||
"""Called when done running code""" | ||
self.source = None | ||
self.code_context = None | ||
self.code_thread = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
if source code is complete, returns "done" | ||
if source code is incomplete, returns "unfinished" | ||
""" | ||
if self.code_context is None: | ||
if self.code_thread is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
self.main_context = greenlet.getcurrent() | ||
self.request_context = None | ||
self.response_queue = queue.Queue() | ||
self.request_or_notify_queue = queue.Queue() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
cd8febb
to
be211d8
Compare
These are very doable changes, but I'm going to close this PR for now because I haven't touched it for so long. |
First draft of moving back to threads from greenlets. So far this is just the reverse of 2e54cbb
The real work here will be making sure I understand threading model in this code I wrote 3.5 years ago.
Todo:
Main thread blocked...
" exception)Latency doesn't seem much worse: as measured by
I get 15.7 for greenlets (the current version), 16.4 for threads