File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 11import os
22import sys
3+ import atexit
34from ctypes import *
45from tempfile import NamedTemporaryFile
56
@@ -38,14 +39,20 @@ def iocInit(dispatcher=None):
3839
3940def safeEpicsExit (code = 0 ):
4041 '''Calls epicsExit() after ensuring Python exit handlers called.'''
41- if hasattr (sys , 'exitfunc' ):
42+ if hasattr (sys , 'exitfunc' ): # py 2.x
4243 try :
4344 # Calling epicsExit() will bypass any atexit exit handlers, so call
4445 # them explicitly now.
4546 sys .exitfunc ()
4647 finally :
4748 # Make sure we don't try the exit handlers more than once!
4849 del sys .exitfunc
50+
51+ elif hasattr (atexit , '_run_exitfuncs' ): # py 3.x
52+ atexit ._run_exitfuncs ()
53+
54+ # calls epicsExitCallAtExits()
55+ # and then OS exit()
4956 epicsExit (code )
5057
5158# The following identifiers will be exported to interactive shell.
You can’t perform that action at this time.
0 commit comments