Skip to content

[Bug] Can't debugging workflow using vscode #238

Closed

Description

@niros1

when run a workflow with vscode debugger attach I get the flowwing error as soon a workflow start.

    int_cmd.do_it(self)
  File "/usr/local/lib/python3.7/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 542, in do_it
    self.method(dbg, *self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_constants.py", line 511, in new_func
    with warnings.catch_warnings():
  File "/usr/local/lib/python3.7/warnings.py", line 458, in __init__
    self._module = sys.modules['warnings'] if module is None else module
  File "/usr/local/lib/python3.7/site-packages/temporalio/worker/workflow_sandbox/_importer.py", line 393, in __getitem__
    return self.current[key]
KeyError: 'warnings'

Environment/Versions

  • OS and processor: [Linux]
  • Temporal Version: Python sdk 0.1b4
  • Are you using Docker or Kubernetes or building Temporal from source? Nor

Activity

  1. cretz commented on Jan 3, 2023

    @cretz
    Contributor

    I will investigate this as part of #213. In the meantime you can disable the sandbox during debug (you may also want to set debug=True for the worker so you don't hit deadlock timeouts).

  2. niros1 commented on Jan 4, 2023

    @niros1
    Author

    10X a lot - I will try it and update

  3. niros1 commented on Jan 4, 2023

    @niros1
    Author

    workflow_runner=workflow_instance.UnsandboxedWorkflowRunner()
    Workaround it.

  4. MauSant commented on Jan 5, 2024

    @MauSant

    workflow_runner=workflow_instance.UnsandboxedWorkflowRunner() Workaround it.

    Thank you!

    It worked for me with the following code:

    from temporalio.client import Client  
    from temporalio.worker import Worker, UnsandboxedWorkflowRunner  
    
    Worker(
            client,
            task_queue=some_task_queue,
            activities=[],
            workflows=[SomeWorkflow],
            debug_mode=True,
            workflow_runner=UnsandboxedWorkflowRunner()
        ):
    
    
    
    
    
  5. challapradyumna commented on Nov 16, 2024

    @challapradyumna

    Created a new worker bypassing the _pydevd_bundle module. Works as of now.

    def new_sandbox_runner() -> SandboxedWorkflowRunner:
        # TODO(cretz): Use with_child_unrestricted when https://github.com/temporalio/sdk-python/issues/254
        # is fixed and released
        invalid_module_member_children = dict(
            SandboxRestrictions.invalid_module_members_default.children
        )
        del invalid_module_member_children["datetime"]
        return SandboxedWorkflowRunner(
            restrictions=dataclasses.replace(
                SandboxRestrictions.default.with_passthrough_modules("_pydevd_bundle"),
                invalid_module_members=dataclasses.replace(
                    SandboxRestrictions.invalid_module_members_default,
                    children=invalid_module_member_children,
                ),
            )
        )
    

    used the above as a workflow runner as below

       worker = Worker(
            client,
            workflow_runner=new_sandbox_runner(),
            task_queue="queue",
            workflows=[Workflow],
            activities=[activity],
            max_concurrent_workflow_tasks = 1,
            max_concurrent_activities= 1
        )
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions