Skip to content

interrupt the app_iter if it tries to write to a closed socket#238

Merged
digitalresistor merged 3 commits intomasterfrom
close-app-iter-on-disconnect
Mar 28, 2019
Merged

interrupt the app_iter if it tries to write to a closed socket#238
digitalresistor merged 3 commits intomasterfrom
close-app-iter-on-disconnect

Conversation

@mmerickel
Copy link
Member

@mmerickel mmerickel commented Mar 26, 2019

fixes #236

@mmerickel mmerickel changed the title interrupt the app_iter if it tries to write to a closed socket WIP interrupt the app_iter if it tries to write to a closed socket Mar 26, 2019
@mmerickel mmerickel force-pushed the close-app-iter-on-disconnect branch from d4d8729 to 5a5418b Compare March 26, 2019 05:37
@mmerickel mmerickel force-pushed the close-app-iter-on-disconnect branch from 5a5418b to 29fb97d Compare March 26, 2019 05:41
if not self.connected:
# if the socket is closed then interrupt the task so that it
# can cleanup possibly before the app_iter is exhausted
# XXX a simple boolean check should not require a lock since it's
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/XXX/NB/ and doing an if on a boolean here is safe in CPython, and probably other interpreters, and there is no race.

I don't think this comment is necessary to be honest.

self.channel.write_soon(app_iter)
return

can_close_app_iter = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for this solution.

@mmerickel mmerickel changed the title WIP interrupt the app_iter if it tries to write to a closed socket interrupt the app_iter if it tries to write to a closed socket Mar 26, 2019
@digitalresistor digitalresistor merged commit bdda44a into master Mar 28, 2019
@digitalresistor digitalresistor deleted the close-app-iter-on-disconnect branch March 28, 2019 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants