Back to articles
Threading Async Together

Threading Async Together

via Dev.toJoseph Boone

Hello readers, I built a proof-of-concept application I call TokenGate. It’s a high performance async/threaded event bus, with control mechanisms designed to be extremely minimalist. The core concept is to produce parallelism in concurrent operations through async token gathering and coordinated threading workers. Here's what "TokenGate" uses to thread an operation: # -- Python 3.12 -- # from token_system import task_token_guard from operations_coordinator import OperationsCoordinator # 1. Decorated standard synchronous function for threading @task_token_guard ( operation_type = ' string_ops ' , tags = { ' weight ' : ' light ' }) def string_operation_task ( task_data ): # This function is now threaded return result # 2. Starts the coordinator (through a running loop) coordinator = OperationsCoordinator () coordinator . start () # 3. finally or an exception stops on close coordinator . stop () Task tokens are generated by using a wrapped decorator. Here's some test results on operations

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles