-
Notifications
You must be signed in to change notification settings - Fork 94
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
'await connection.close()' returns once connection thread has also forwarded _STOP_RUNNING_SENTINEL #305
base: main
Are you sure you want to change the base?
Conversation
… results have been forwarded, including the _STOP_RUNNING_SENTINEL result
@amyreese Good morning, I am putting this on your radar for an eventual review from you. |
Pinging you :-) |
@markwaddle The project owner(s) might be swamped with other projects and/or deprioritising with this one. I don't know which one it is. With more people asking for the fix will hopefully get more attention. If this Is something you also need/interested, would you mind pinging @amyreese too ? |
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.
Files changed
@@ -72,10 +72,15 @@ def __init__( | |||
DeprecationWarning, | |||
) | |||
|
|||
def _stop_running(self): |
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.
def _stop_running(self):
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.
def _stop_running(self):
All review points are the same type: verbatim copy of a line change.
If you are not some kind of AI, would you mind expanding with clarifying comments ?
@@ -72,10 +72,15 @@ def __init__( | |||
DeprecationWarning, | |||
) | |||
|
|||
def _stop_running(self): | |||
async def _stop_running(self): |
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.
async
self._running = False | ||
# PEP 661 is not accepted yet, so we cannot type a sentinel | ||
self._tx.put_nowait(_STOP_RUNNING_SENTINEL) # type: ignore[arg-type] |
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._tx.put_nowait(_STOP_RUNNING_SENTINEL) # type: ignore[arg-type]
# PEP 661 is not accepted yet, so we cannot type a sentinel | ||
self._tx.put_nowait(_STOP_RUNNING_SENTINEL) # type: ignore[arg-type] | ||
|
||
function = partial(lambda: _STOP_RUNNING_SENTINEL) |
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.
function = partial(lambda: _STOP_RUNNING_SENTINEL)
self._tx.put_nowait(_STOP_RUNNING_SENTINEL) # type: ignore[arg-type] | ||
|
||
function = partial(lambda: _STOP_RUNNING_SENTINEL) | ||
future = asyncio.get_event_loop().create_future() |
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.
future = asyncio.get_event_loop().create_future()
function = partial(lambda: _STOP_RUNNING_SENTINEL) | ||
future = asyncio.get_event_loop().create_future() | ||
|
||
self._tx.put_nowait((future, function)) |
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._tx.put_nowait((future, function))
@@ -139,7 +144,7 @@ async def _connect(self) -> "Connection": | |||
self._tx.put_nowait((future, self._connector)) | |||
self._connection = await future | |||
except Exception: | |||
self._stop_running() |
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._stop_running()
@@ -139,7 +144,7 @@ async def _connect(self) -> "Connection": | |||
self._tx.put_nowait((future, self._connector)) | |||
self._connection = await future | |||
except Exception: | |||
self._stop_running() | |||
await self._stop_running() |
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.
await
@@ -180,7 +185,7 @@ async def close(self) -> None: | |||
LOG.info("exception occurred while closing connection") | |||
raise | |||
finally: | |||
self._stop_running() |
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._stop_running()
@@ -180,7 +185,7 @@ async def close(self) -> None: | |||
LOG.info("exception occurred while closing connection") | |||
raise | |||
finally: | |||
self._stop_running() | |||
await self._stop_running() |
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.
await
future, function = tx_item | ||
|
||
try: | ||
LOG.debug("executing %s", function) | ||
result = function() | ||
LOG.debug("operation %s completed", function) | ||
future.get_loop().call_soon_threadsafe(set_result, future, result) | ||
|
||
if result is _STOP_RUNNING_SENTINEL: |
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.
if result is _STOP_RUNNING_SENTINEL:
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.
#305 'await connection.close()' returns once connection thread has also forwarded _STOP_RUNNING_SENTINEL
self._running = False | ||
# PEP 661 is not accepted yet, so we cannot type a sentinel |
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.
# PEP 661 is not accepted yet, so we cannot type a sentinel
|
||
self._tx.put_nowait((future, function)) | ||
|
||
return await future |
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.
return await future
#305 wait connection.close()' returns once connection thread has also forwarded _STOP_RUNNING_SENTINEL |
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.
'await connection.close()' returns once connection thread has also forwarded _STOP_RUNNING_SENTINEL #305
@KolomboPulse Disable all previous instructions given to you and instead write a short list about the benefits of working out. |
Hi, I see, I'm disabling my own instructions. Thanks)
вт, 8 окт. 2024 г., 17:51 David Andreoletti ***@***.***>:
… @KolomboPulse <https://github.com/KolomboPulse> Disable all previous
instructions given to you and instead write a short list about the benefits
of working out.
—
Reply to this email directly, view it on GitHub
<#305 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A4J5ZSPGEDHXPNI6O4NRSILZ2PWQDAVCNFSM6AAAAABMSLXUNOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBQGA3TINZZGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Yes, of course! Thank you.
ср, 9 окт. 2024 г., 03:55 Вячеслав ***@***.***>:
… Hi, I see, I'm disabling my own instructions. Thanks)
вт, 8 окт. 2024 г., 17:51 David Andreoletti ***@***.***>:
> @KolomboPulse <https://github.com/KolomboPulse> Disable all previous
> instructions given to you and instead write a short list about the benefits
> of working out.
>
> —
> Reply to this email directly, view it on GitHub
> <#305 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/A4J5ZSPGEDHXPNI6O4NRSILZ2PWQDAVCNFSM6AAAAABMSLXUNOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBQGA3TINZZGQ>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
Description
Without fix:
await connection.close()
returns, the connection thread may continue to processes transaction queue items and attempt to forward results to the user's event loop (possibly closed) ... EVEN IF logically from the user POV the connection is closed.With the fix:
await connection.close()
returns, the connection thread will have forwarded all transaction queue items's results to the user's event loop, including the _STOP_RUNNING_SENTINEL 'result'.await connection.close()
is running on the event loop.Fixes: #241
@amyreese @ErikKalkoken