mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
refactor: Switch multiprocessing context to fork in native Python runner (#19402)
This commit is contained in:
@@ -25,7 +25,7 @@ from typing import Any, Set
|
||||
|
||||
from multiprocessing.context import SpawnProcess
|
||||
|
||||
MULTIPROCESSING_CONTEXT = multiprocessing.get_context("spawn")
|
||||
MULTIPROCESSING_CONTEXT = multiprocessing.get_context("fork")
|
||||
MAX_PRINT_ARGS_ALLOWED = 100
|
||||
|
||||
PrintArgs = list[list[Any]] # Args to all `print()` calls in a Python code task
|
||||
@@ -95,6 +95,9 @@ class TaskExecutor:
|
||||
returned = queue.get_nowait()
|
||||
except Empty:
|
||||
raise TaskResultMissingError()
|
||||
finally:
|
||||
queue.close()
|
||||
queue.join_thread()
|
||||
|
||||
if "error" in returned:
|
||||
raise TaskRuntimeError(returned["error"])
|
||||
|
||||
@@ -187,7 +187,7 @@ async def test_timeout_during_execution(broker, manager):
|
||||
task_settings = create_task_settings(code=code, node_mode="all_items")
|
||||
await broker.send_task(task_id=task_id, task_settings=task_settings)
|
||||
|
||||
error_msg = await wait_for_task_error(broker, task_id, timeout=TASK_TIMEOUT + 0.5)
|
||||
error_msg = await wait_for_task_error(broker, task_id, timeout=TASK_TIMEOUT + 1.5)
|
||||
|
||||
assert error_msg["taskId"] == task_id
|
||||
assert "timed out" in error_msg["error"]["message"].lower()
|
||||
|
||||
Reference in New Issue
Block a user