-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Add mechanism to register (noisy) signal handler #2631
Conversation
That is indeed a nice change! There is nonetheless one thing i would like to ask of you: Could you describe in a few words the behaviours when noisy is set to true or false in the docstring of the method? It is quite important as it has significant impact on the runtime behavior. |
Also this section should be adapted: https://github.com/ponylang/ponyc/blob/master/packages/signals/sig.pony#L42 |
I understand the reasoning behind this but I think this needs further
discussion.
We need to verify that any noisy signal can be cancelled otherwise the
program is unable to exit.
…On Thu, Apr 5, 2018, 4:04 AM Matthias Wahl ***@***.***> wrote:
Also this section should be adapted:
https://github.com/ponylang/ponyc/blob/master/packages/signals/sig.pony#L42
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2631 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAL0PLvxEifme4MucT9sMyJYZiAiSaB7ks5tldAIgaJpZM4TH9rg>
.
|
@SeanTAllen Cancelled by who, the user? If it helps, we can create a whitelist of signals that are allowed to be registered in a noisy way. |
Yes cancelled by the user. If its noisy then you need to be able to shut it down so that the program can exit if the signal is never received. related: I dont think "noisy" should be the name that is exposed in the API. |
packages/signals/signal_handler.pony
Outdated
@@ -15,14 +15,14 @@ actor SignalHandler | |||
let _sig: U32 | |||
var _event: AsioEventID | |||
|
|||
new create(notify: SignalNotify iso, sig: U32) => | |||
new create(notify: SignalNotify iso, sig: U32, noisy : Bool = false) => |
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.
Small formatting issue - can you remove the whitespace before the :
, to make the code style match the style guide?
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.
Fixed.
To cancel the noisy listener, I think I agree that finding a better name for this than |
Maybe Something like:
|
Noisy was really confusing for me as I was browsing the codebase. I wish
there was a better term to describe what it meant.
…On Thu, Apr 5, 2018 at 10:25 AM, Joe Eli McIlvain ***@***.***> wrote:
To cancel the noisy listener, I *think* dispose should already do the
trick here.
I agree that finding a better name for this than noisy would be good (but
currently not sure what to suggest). And I also agree that the consequences
of the parameter need to be explained in a docstring for this method.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2631 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAtyRORauqhz4vBIZBFnT1RPmbxH71LNks5tllN2gaJpZM4TH9rg>
.
|
FWIW, my understanding of the word "noisy" is used in opposite of "quiescent" (which appears in scheduler.c). The runtime can shut down if all possible sources of messages are quiet (not sending anything) and will be quiet in the future. |
Yeah, that's where "noisy" comes from, and it does make some sense after realizing the relationship to "quiescence" - it's just a bit of an odd / novel use of the word that I'm not aware of being used in any other programming contexts - perhaps because pony's model for detecting quiescence to terminate the program is also novel (as far as I know - I may be unaware of some prior art here). |
I think noisy fine in the codebase when not exposed to folks via a Pony API.
When I get around to creating a Pony API for the various Pony ASIO ffi
methods, I'd want to use a different name there was well.
…On Thu, Apr 5, 2018, 2:52 PM Joe Eli McIlvain ***@***.***> wrote:
Yeah, that's where "noisy" comes from, and it does make some sense after
realizing the relationship to "quiescence" - it's just a bit of an odd /
novel use of the word that I'm not aware of being used in any other
programming contexts - perhaps because pony's model for detecting
quiescence to terminate the program is also a bit novel (as far as I know).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2631 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAL0PJ_hP1tsCK0G1-sQCXXr--jZhIAHks5tlmfegaJpZM4TH9rg>
.
|
@jemc Changed to "wait" |
packages/signals/signal_handler.pony
Outdated
@@ -10,19 +10,22 @@ use @pony_asio_event_destroy[None](event: AsioEventID) | |||
actor SignalHandler | |||
""" | |||
Listen for a specific signal. | |||
|
|||
If the wait parameter is true, the program will not terminate until the SignalHandler's dispose method is called. | |||
|
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.
This extra empty line isn't needed.
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.
Looks good to me, other than the small empty line comment I made above.
Anybody else have things to say about this?
Fine by me. Should this have a changelog+added tag added? |
@jemc Just removed the whitespace. |
1 similar comment
@jemc Just removed the whitespace. |
packages/signals/signal_handler.pony
Outdated
@@ -10,19 +10,21 @@ use @pony_asio_event_destroy[None](event: AsioEventID) | |||
actor SignalHandler | |||
""" | |||
Listen for a specific signal. | |||
If the wait parameter is true, the program will not terminate until the SignalHandler's dispose method is called. |
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.
i would also add: "or if the SignalNotify
returns false, after handling the signal"
as this also disposes the SignalHandler and unsubscribes from asio.
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.
I think that "logic" is already documented in SignalNotify.pony:
Called with the the number of times the signal has fired since this was
last called. Return false to stop listening for the signal.
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.
True point. I would add it nonetheless, as it is important for users to understand under which circumstances waiting stops. It is more convenient to users to have this information in one place.
Thank you for the PR, it looks very good.
This allows programs that are waiting on a signal to proceed to work. Sometimes, there are programs that are waiting for an alarm, or similar prior to performing I/O. This was impossible, because signal handlers were never registered as noisy actors in asio. This allows for an optional named parameter to be passed with that context.
@mfelsche Added a bit more info to the docstring |
Thanks @sargun |
This allows programs that are waiting on a signal to proceed to
work. Sometimes, there are programs that are waiting for an alarm,
or similar prior to performing I/O.
This was impossible, because signal handlers were never registered
as noisy actors in asio. This allows for an optional named parameter
to be passed with that context.
A simple example of a program that was not supposed to terminate until it received a signal:
In order to fix this behaviour under the PR, the signal handler can be created like so: