MCPcopy
hub / github.com/redis/redis-py / run_in_thread

Method run_in_thread

redis/client.py:1584–1613  ·  view source on GitHub ↗
(
        self,
        sleep_time: float = 0.0,
        daemon: bool = False,
        exception_handler: Optional[Callable] = None,
        pubsub=None,
        sharded_pubsub: bool = False,
    )

Source from the content-addressed store, hash-verified

1582 return message
1583
1584 def run_in_thread(
1585 self,
1586 sleep_time: float = 0.0,
1587 daemon: bool = False,
1588 exception_handler: Optional[Callable] = None,
1589 pubsub=None,
1590 sharded_pubsub: bool = False,
1591 ) -> "PubSubWorkerThread":
1592 for channel, handler in self.channels.items():
1593 if handler is None:
1594 raise PubSubError(f"Channel: '{channel}' has no handler registered")
1595 for pattern, handler in self.patterns.items():
1596 if handler is None:
1597 raise PubSubError(f"Pattern: '{pattern}' has no handler registered")
1598 for s_channel, handler in self.shard_channels.items():
1599 if handler is None:
1600 raise PubSubError(
1601 f"Shard Channel: '{s_channel}' has no handler registered"
1602 )
1603
1604 pubsub = self if pubsub is None else pubsub
1605 thread = PubSubWorkerThread(
1606 pubsub,
1607 sleep_time,
1608 daemon=daemon,
1609 exception_handler=exception_handler,
1610 sharded_pubsub=sharded_pubsub,
1611 )
1612 thread.start()
1613 return thread
1614
1615
1616class PubSubWorkerThread(threading.Thread):

Calls 3

PubSubErrorClass · 0.90
PubSubWorkerThreadClass · 0.85
startMethod · 0.45