-
Notifications
You must be signed in to change notification settings - Fork 9
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
Fixup atexit handling #35
Conversation
allow interactive_ioc(call_exit=False) to cleanup and exit cleanly.
Codecov Report
@@ Coverage Diff @@
## master #35 +/- ##
==========================================
- Coverage 85.74% 85.50% -0.25%
==========================================
Files 13 13
Lines 807 828 +21
==========================================
+ Hits 692 708 +16
- Misses 115 120 +5
Continue to review full report at Codecov.
|
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'm a bit hazy on the details of how we stop the IOC cleanly, so my comments reflect that...
def __call__(self): | ||
safeEpicsExit() | ||
def __repr__(self): # hack to exit when "called" with no parenthesis | ||
sys.exit(0) |
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 guess this will make code.interact
raise SystemExit
which will call safeEpicsExit
, Why do we call sys.exit() here rather than safeEpicsExit?
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.
sys.exit()
will work the same regardless of how interactive_ioc()
is called. This keeps the handling of call_exit=True
vs. call_exit=False
contained to interactive_ioc()
where SystemExit
is now caught.
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 pretty good to me. Pity about that bug back in c9548f6!
Didn't know that EPICS had its own at exit framework; in fact, didn't know that EPICS handled exit at all now (apart from pulling the plug, like we always used to).
@@ -97,7 +97,11 @@ def auto_decode(result, func, args): | |||
iocInit.argtypes = () | |||
|
|||
epicsExit = Com.epicsExit | |||
epicsExit.argtypes = () | |||
epicsExit.argtypes = (c_int,) |
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.
Oops.
Looks like this was my mistake, back in commit c9548f6
epicsExit() | ||
|
||
elif hasattr(atexit, '_run_exitfuncs'): # py 3.x | ||
atexit._run_exitfuncs() |
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.
Do we need to do the same dance as above with sys.exitfunc
to make sure we don't get multiple executions of exit handlers?
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.
Not as I read it. _run_exitfuncs()
(like epicsExitCallAtExits()
) removes callbacks which have run.
def __repr__(self): # hack to exit when "called" with no parenthesis | ||
sys.exit(0) | ||
def __call__(self, code=0): | ||
sys.exit(code) |
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.
Why aren't we calling epicsExit
here anymore?
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'm guessing you answered this above in #35 (comment)
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.
Hopefully :)
@thomascobb, did I accidentally just delete one of your comments? I see a message to that effect upstream! |
This has been around for quite some time. It's worth noting that there are some platform specific differences.
|
epicsExit(int)
to avoid exit with ~random code.atexit._run_exitfuncs()
with py 3.xinteractive_ioc(call_exit=False)