Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upWIP - Moving back to threads #681
Open
Conversation
This was referenced Apr 22, 2017
| @@ -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 | |||
This comment has been minimized.
This comment has been minimized.
| 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 |
This comment has been minimized.
This comment has been minimized.
|
|
||
| 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 |
This comment has been minimized.
This comment has been minimized.
|
|
||
| def _unload_code(self): | ||
| """Called when done running code""" | ||
| self.source = None | ||
| self.code_context = None | ||
| self.code_thread = None |
This comment has been minimized.
This comment has been minimized.
| 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: |
This comment has been minimized.
This comment has been minimized.
| self.main_context = greenlet.getcurrent() | ||
| self.request_context = None | ||
| self.response_queue = queue.Queue() | ||
| self.request_or_notify_queue = queue.Queue() |
This comment has been minimized.
This comment has been minimized.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
thomasballinger commentedApr 22, 2017
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