Skip to content

Commit

Permalink
sapling: fix threading cyclic import error when calling traceback
Browse files Browse the repository at this point in the history
Summary:

Test Plan:

Before:
```
./build/fbcode_builder/getdeps.py --allow-system-packages test --src-dir=. sapling --num-jobs=32 --filter test-fb-ext-grpcheck.t --retry 0
...
-  You should be in devs group.
+  unknown python exception <class 'AttributeError'> Some(AttributeError("partially initialized module 'threading' has no attribute 'RLock' (most likely due to a circular import)")) (no-eol)
+  [1]

```

After:
```
----------------------------------------------------------------------
# Ran 1 tests, 0 skipped, 0 failed.
passed on try 0
```
  • Loading branch information
ahornby committed Oct 27, 2024
1 parent f755624 commit 8b9858e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions eden/scm/lib/commands/cmdpy/src/hgpython.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ impl HgPython {
) -> i32 {
let gil = Python::acquire_gil();
let py = gil.python();
// Workaround threading cyclic import error from format_py_error
// traceback import. Needs importing before the error happens.
if let Err(e) = PyModule::import(py, "threading") {
let message = format!("error importing python threading module: {:?}", e);
let _ = io.write_err(message);
return 1;
}
match self.run_hg_py(py, args, io, config, skip_pre_hooks) {
// The code below considers the following exit scenarios:
// - `PyResult` is `Ok`. This means that the Python code returned
Expand Down

0 comments on commit 8b9858e

Please sign in to comment.