Open o3bvv opened 4 years ago
FDB does nothing with POSIX signal handlers, BUT it uses ctypes to work with Firebird client library that certainly does something to finalize so/ddl gracefuly. The library initialization is deferred until first request that needs it, i.e. connect, create_database or service.connect, so you can choose the client library to use and to allow fdb to be imported (or even installed) without Firebird installed. You can force the library initialization using load_api() call. See https://fdb.readthedocs.io/en/latest/reference.html#fdb.load_api
Try using load_api() before you install the signal handlers.
Yes, that's exactly what I've thought about and tried to do.
I've called fbd.load_api()
before setting up the signal handler and I've commented out that call inside fbd.connect()
: the app reacts as expected.
But calling fbd.connect()
(even with disabled internal call to load_api()
) still spoils things up and sending a signal to the app kills it immediately.
I've just checked the work on a windows server and it's fine, though:
Of cource, on windows SetConsoleCtrlHandler()
is used instead of signal()
, but in my case it's the target platform, so I'm fine with postponing the issue at unix-like systems. Maybe it's a Python's bug, like this one: https://bugs.python.org/issue27889
I'd appreciate if you notify me in case you find a resolution for this or similar issue.
Thanks for your responses!
Hello again,
I'm trying to investigate an issue with behavior signal handlers during and after invocation of
fdb.connect()
.I have a handler for
SIGINT
andSIGTERM
which is used for application's graceful shutdown, e.g.:The handler works perfectly before the call to
fdb.connect()
: it captures signals, reports the exit request, notifies subscribers and the main thread waits till all shut down work is finished:But if
fdb.connect()
is invoked, the thread is killed immediately after receiving a signal:As you can see, exit handler was invoked, but the app was killed before finishing (no log messages, as before). It's just a matter of chance that the handler's message managed to propagate to stdout via logger.
If the connection takes too long and the app gets a signal during connection, the thread just bails:
I've investigated signal handlers and masks before and after the call to
fdb.connect()
and they are the same. The rest of the app works as expected.Noteworthy, setting signal handlers after the call to
fdb.connect()
once again makes the app to behave as expected. However, this cannot be considered as a workaround, as the app bails during the invocation offdb.connect()
.I've tried to investigate C++ sources of the driver and Python sources of its wrapper, but I couldn't spot any signal management inside them so far.
Could you please provide any suggestions regarding possible root cause?
My OS is
macOS 10.15.1
and the driver is provided byFirebirdCS-2.5.9-27139-x86_64.pkg
.