Core

All applications have to have some kind of outer blcok.

Globals

core.running

This is a boolean that the application is running. It can be turned off by an application, but the stop() function is usually used.

core.taskManager

This is a reference to the TaskManager instance that is used to schedule some operation. There is only one task manager instance in an application.

core.deferredFns

This is a list of function calls to make after all of the asyncore.loop processing has completed. This is a list of (fn, args, kwargs) tuples that are appended to the list by the deferred() function.

core.sleeptime

This value is used to “sleep” the main thread for a certian amount of before continuing on to the asyncore loop. It is used to be friendly to other threads that may be starved for processing time. See enable_sleeping().

Functions

core.run()

This function is called by a BACpypes application after all of its initialization is complete.

core.stop(*args)
Parameters:args – optional signal handler arguments

This function is called to stop a BACpypes application. It resets the running boolean value. This function also installed as a signal handler responding to the TERM signal so you can stop a background (deamon) process:

$ kill -TERM 12345
core.print_stack(sig, frame)
Parameters:
  • sig – signal
  • frame – stack trace frame
core.deferred(fn, *args, **kwargs)
Parameters:
  • fn – function to call
  • args – regular arguments to pass to fn
  • kwargs – keyword arguments to pass to fn

This function is called to postpone a function call until after the asyncore.loop processing has completed. See run().

core.enable_sleeping([stime])
Parameters:stime – amount of time to sleep, defaults to one millisecond

BACpypes applications are generally written as a single threaded application, the stack is not thread safe. However, applications may use threads at the application layer and above for other types of work. This function allows the main thread to sleep for some small amount of time so that it does not starve child threads of processing time.

When sleeping is enabled, and it only needs to be enabled for multithreaded applications, it will put a damper on the thruput of the application.