Skip to content

tdfs4ds.utils.td_context

tdfs4ds.utils.td_context

teradataml's current context: is one open, close it with a time limit, forget it.

teradataml changed where it keeps the connection. Up to 20.0.0.10 it is a module global, teradataml.context.context.td_connection. From 20.0.0.12 the context is an object, _global_context_instance (top of _context_stack), and the module global stays None. Code that only read the global saw no connection at all on 20.0.0.12 (0.3.6.2's keep-alive never pinged, and its bounded close returned at once) while tdml.remove_context() still ran its garbage collector over the dead connection and blocked forever. Both layouts are read here, once.

tdml.remove_context() sends statements (query band reset, DROP VIEW of its temporary objects) before closing. Over a connection the network dropped while idle, the driver waits for an answer that never comes, so a close must be bounded.

logger module-attribute

logger = getLogger('tdfs4ds')

CLOSE_TIMEOUT module-attribute

CLOSE_TIMEOUT = 30

_bounded

_bounded(fn, timeout, name)

Run fn in a daemon thread. Returns (finished, result_or_exception).

_ctx_module

_ctx_module()

context_open

context_open()

True when teradataml holds an open connection (either layout).

abandon_context

abandon_context()

Forget the current teradataml connection without sending anything over it.

close_context_bounded

close_context_bounded(timeout=CLOSE_TIMEOUT)

Close the teradataml context, giving up after timeout seconds.

Returns 'none' (nothing open), 'closed', 'failed' (the close raised; the context is cleared anyway) or 'abandoned' (it did not return in time: the context is cleared and the stuck call is left in its daemon thread).