Skip to content

Commit b0ec33c

Browse files
committed
Update journal entries and documentation for LangGraph CLI debugging and environment variables
- Modify journal entries for April 11, 16, and 17, enhancing references to LangGraph CLI debugging in PyCharm and handling blocking errors in async code. - Add new documentation pages for debugging in PyCharm and the BG_JOB_ISOLATED_LOOPS environment variable, providing detailed instructions and best practices. - Remove outdated debugging documentation to streamline resources.
1 parent 5638225 commit b0ec33c

9 files changed

Lines changed: 94 additions & 16 deletions

journals/2025_04_11.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
- #Discovered [[Logseq/Plugin/logseq-fenced-code-plus]] has support for [[Mermaid]]. Too bad plugins aren't supported when using [[Logseq/Publish]] to web
33
- ## Langchain Ecosystem
44
- #Filed
5-
- [[langgraph/CLI/How To/Debug/in PyCharm]]
5+
- [[langgraph/CLI/dev/How To/Debug/PyCharm]]
66
- [[langgraph/CLI/dev/How To/Handle blocking errors in async code]]

journals/2025_04_16.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
## Python
22
- [[Py/PEP/570 Python Positional-Only Parameters]]
3-
- ### Async
4-
-
3+
- ### Async and LangChain Ecosystem
4+
- [[langgraph/CLI/dev/How To/Handle blocking errors in async code]]

journals/2025_04_17.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Langchain Ecosystem
2+
- #Updated
3+
- [[langgraph/CLI/dev/How To/Debug/PyCharm]]
4+
- #Filed
5+
- [[langgraph/CLI/EnvVar/BG_JOB_ISOLATED_LOOPS]]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# [Attach to process | PyCharm Documentation](https://www.jetbrains.com/help/pycharm/attach-to-process.html)
2+
- ## Summary
3+
- > PyCharm provides a way to attach the debugger to a Python local process, while running a Python script launched either from your operating system or using the PyCharm terminal, but NOT in the debug mode. Note that you cannot attach to a remote process.
4+
- ## How To
5+
- Run | Attach to Process - Option+Shift+F5 (`⌥⇧F5`) #Keyshort
6+
- alternatively, use [[PyCharm/Keyshort/Find Action]] and search for Attach to Process
7+
- type the name of the process
8+
- hit enter
9+
-
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
tags:: [[Keyshort]]
2+
3+
- # [Find Action](https://www.jetbrains.com/help/pycharm/mastering-keyboard-shortcuts.html)
4+
- | Cmd+Shift+A (`⌘⇧A`) | [Find Action](https://www.jetbrains.com/help/pycharm/searching-everywhere.html#find_action) - Find a command and execute it, open a tool window, or search for a setting. |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# [BG_JOB_ISOLATED_LOOPS](https://langchain-ai.github.io/langgraph/cloud/reference/env_var/?h=bg_job_isolated_loops#bg_job_isolated_loops)
2+
- Set ==BG_JOB_ISOLATED_LOOPS== to `True` to execute background runs in an isolated event loop separate from the serving API event loop.
3+
- This environment variable should be set to `True` if the implementation of a graph/node contains synchronous code. In this situation, the synchronous code will block the serving API event loop, which may cause the API to be unavailable. A symptom of an unavailable API is continuous application restarts due to failing health checks.
4+
- Defaults to `False`.

pages/langgraph___CLI___How To___Debug___in PyCharm.md

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# How to use a #Debugger with `langgraph dev` in [[PyCharm]]
2+
- ## Partially Working
3+
- ### Creating a [[PyCharm/Run Configuration]] for `langgraph-dev --allow-blocking`
4+
- [[langgraph/GitHub/Discussion/25/04/How to use langgraph dev in a PyCharm Debugger]]
5+
- #### [[My Notes]]
6+
- Marked as "partially working" because the `--allow-blocking` argument is needed because [[pydevd]] uses blocking operations to resolve symlinks to files, which triggers [[langgraph]]'s detection using [[Py/Lib/blockbuster]]
7+
- #### PyCharm Run Configuration parameters
8+
- **Run Configuration Type** - Python
9+
- **Virtual Environment** - Select your project's virtual environment
10+
- **Run Configuration Subtype** - `script`
11+
- **Script Path**: absolute path to the `langgraph` executable within the virtualenv, found with `which langgraph`
12+
- (anyone know how to make this more dynamic? just putting in `langgraph` yields `FileNotFoundError: [Errno 2] No such file or directory: 'langgraph'`
13+
- **Script Parameters**: `dev --allow-blocking`
14+
- no need for `--debug-port`, which is for  [[Py/debugpy]]  instead of PyCharm's  [[pydevd]]
15+
- ## Not Working
16+
- ### Attach to Process
17+
- #### 1 - `langgraph dev` in a terminal, then use [[PyCharm/Debug/Attach to Process]]
18+
- #### To reproduce
19+
- in a terminal - run `langgraph dev`
20+
- initiate [[PyCharm/Debug/Attach to Process]]
21+
- #### Expected Behavior - PyCharm is able to debug an external process
22+
- #### Actual Behavior - `error: Execution was interrupted, reason: signal SIGSTOP`.
23+
- ```
24+
Attaching to a process with PID=85,887
25+
/path/to/python/env/bin/python /Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach_pydevd.py --port 59663 --pid 85887
26+
Running: lldb --no-lldbinit --script-language Python -o 'process attach --pid 85887' -o 'command script import "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/linux_and_mac/lldb_prepare.py"' -o 'load_lib_and_attach "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach.dylib" 0 "import sys;sys.path.append(\"/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev\");sys.path.append(\"/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process\");import attach_script;attach_script.attach(port=59663, host=\"127.0.0.1\", protocol=\"\", debug_mode=\"\");" 0' -o 'process detach' -o 'script import os; os._exit(1)'
27+
(lldb) process attach --pid 85887
28+
Process 85887 stopped
29+
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
30+
frame #0: 0x00000001935353c8 libsystem_kernel.dylib`__semwait_signal + 8
31+
libsystem_kernel.dylib`__semwait_signal:
32+
-> 0x1935353c8 <+8>: b.lo 0x1935353e8 ; <+40>
33+
0x1935353cc <+12>: pacibsp
34+
0x1935353d0 <+16>: stp x29, x30, [sp, #-0x10]!
35+
0x1935353d4 <+20>: mov x29, sp
36+
Target 0: (python3.12) stopped.
37+
Executable module set to "/path/to/python/3.12.1/bin/python3.12".
38+
Architecture set to: arm64-apple-macosx-.
39+
(lldb) command script import "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/linux_and_mac/lldb_prepare.py"
40+
(lldb) load_lib_and_attach "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach.dylib" 0 "import sys;sys.path.append(\"/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev\");sys.path.append(\"/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process\");import attach_script;attach_script.attach(port=59663, host=\"127.0.0.1\", protocol=\"\", debug_mode=\"\");" 0
41+
/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach.dylib
42+
success
43+
import sys;sys.path.append("/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev");sys.path.append("/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process");import attach_script;attach_script.attach(port=59663, host="127.0.0.1", protocol="", debug_mode="");
44+
error: error: Execution was interrupted, reason: signal SIGSTOP.
45+
The process has been returned to the state before expression evaluation.
46+
(lldb) process detach
47+
Process 85887 detached
48+
(lldb) script import os; os._exit(1)
49+
Traceback (most recent call last):
50+
File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach_pydevd.py", line 79, in <module>
51+
main(process_command_line(sys.argv[1:]))
52+
File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach_pydevd.py", line 74, in main
53+
add_code_to_python_process.run_python_code(
54+
File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/add_code_to_python_process.py", line 533, in run_python_code_mac
55+
subprocess.check_call(' '.join(cmd), shell=True, env=env)
56+
File "/path/to/python/3.12.1/lib/python3.12/subprocess.py", line 413, in check_call
57+
raise CalledProcessError(retcode, cmd)
58+
subprocess.CalledProcessError: Command 'lldb --no-lldbinit --script-language Python -o 'process attach --pid 85887' -o 'command script import "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/linux_and_mac/lldb_prepare.py"' -o 'load_lib_and_attach "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process/attach.dylib" 0 "import sys;sys.path.append(\"/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev\");sys.path.append(\"/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd_attach_to_process\");import attach_script;attach_script.attach(port=59663, host=\"127.0.0.1\", protocol=\"\", debug_mode=\"\");" 0' -o 'process detach' -o 'script import os; os._exit(1)'' returned non-zero exit status 1.
59+
```
60+
- #### 2 - `langgraph dev` in a [[PyCharm/Run Configuration]], then use [[PyCharm/Debug/Attach to Process]]
61+
- setup - same as 1, except running `langgraph dev` using a run configuration
62+
- same result as 1
63+
-

pages/langgraph___CLI___dev___How To___Handle blocking errors in async code.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# How to handle langgraph's blocking error
2-
- ## sample error - "LangGraph dev identified a synchronous blocking call in your code"
2+
- ## sample error 1 - "LangGraph dev identified a synchronous blocking call in your code"
33
- ```
44
Heads up! LangGraph dev identified a synchronous blocking call in your code. When running in an ASGI web server, blocking calls can degrade performance for everyone since they tie up the event loop.
55
Here are your options to fix this:
@@ -14,6 +14,9 @@
1414
```
1515
- ## Sub-optimal workarounds
1616
- For development: Run 'langgraph dev --allow-blocking'
17-
- For deployment: Set 'BG_JOB_ISOLATED_LOOPS=true' environment variable
17+
- For deployment: Set 'BG_JOB_ISOLATED_LOOPS=true' environment variable [[langgraph/CLI/EnvVar/BG_JOB_ISOLATED_LOOPS]]
1818
- ## Better workarounds
19-
- search your code for synchronous clients and replace them with async clients
19+
- search your code for synchronous clients and replace them with async clients
20+
- ## Resources
21+
- [blockbuster causes blocking error via tiktoken in async context with latest langgraph-api · Issue #4218 · langchain-ai/langgraph](https://github.com/langchain-ai/langgraph/issues/4218)
22+
- References workarounds; recommendation from

0 commit comments

Comments
 (0)