(target, args=(), kwargs=None)
| 262 | |
| 263 | @staticmethod |
| 264 | def thread_run(target, args=(), kwargs=None): |
| 265 | kwargs = kwargs or {} |
| 266 | |
| 267 | def func(target, queue, args, kwargs): |
| 268 | try: |
| 269 | queue.put(target(*args, **kwargs)) |
| 270 | except Exception as e: |
| 271 | queue.put(e) |
| 272 | |
| 273 | queue = Queue() |
| 274 | thread = Thread(target=func, args=(target, queue, args, kwargs)) |
| 275 | thread.start() |
| 276 | thread.join() |
| 277 | result = queue.get() |
| 278 | if isinstance(result, Exception): |
| 279 | raise result |
| 280 | return result |
| 281 | |
| 282 | @staticmethod |
| 283 | def safe_asyncio_run(coro): |