Miscellaneous¶
Login state¶
The SDK logs in to the server in the background at import time, so right after importing the module the login may still be running.
You can check the login state with cobalstamp.ready():
import cobalstamp
cobalstamp.ready() # True if the SDK has finished logging in
It returns True only once the login succeeded. Polling it before your
first call to cobalstamp.mark is usually unnecessary, because marking
waits for the login internally.
Multiprocessing¶
Cobalstamp Python SDK uses a C/C++ python extension and this is generally not safe to use with the ‘fork’ start method (ex. like pytorch, tensorflow, etc.) Thus, when using multiprocessing, you need to use the ‘spawn’ start method instead of the ‘fork’ start method.
import multiprocessing
multiprocessing.set_start_method('spawn', force=True)
Slow connection¶
In case you are on a slow connection, you can increase the timeout for the connection to the server.
export COBALSTAMP_TIMEOUT=20
python -c "import cobalstamp; print(cobalstamp.__version__)"
Exit On Interrupt (EOI)¶
Many C/C++ written python modules won’t react to a ctrl-c interruption (or equivalent). The C/C++ part will first finish its execution and the python part will then handle any ctrl-c.
Calling cobalstamp.eoi() after loading the module
import cobalstamp
cobalstamp.eoi()
allows any ctrl-c to kill the C/C++ part immediately.
You can deactivate eoi() with cobalstamp.uneoi()
By default, this uncommon behavior is disabled.