mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-01 00:27:20 -05:00
chore: merge main into pack probes
This commit is contained in:
commit
e4391d4c7a
2 files changed
+18
-7
No files matched your search
+15
-7
@@ -69,6 +69,7 @@ import stat
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import threading
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
@@ -454,15 +455,22 @@ def copy_regular(src: Path, dest: Path) -> None:
|
||||
shutil.copyfileobj(handle, out)
|
||||
|
||||
|
||||
# The working directory belongs to the process. Two passes in threads that
|
||||
# each saved and restored it could leave the process in the other's root,
|
||||
# then in a folder deleted with its workspace.
|
||||
_CWD_LOCK = threading.Lock()
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def working_directory(path: Path) -> Iterator[None]:
|
||||
"""contextlib.chdir, which Python 3.9 lacks."""
|
||||
before = Path.cwd()
|
||||
os.chdir(path)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
os.chdir(before)
|
||||
"""contextlib.chdir, which Python 3.9 lacks, one thread at a time."""
|
||||
with _CWD_LOCK:
|
||||
before = Path.cwd()
|
||||
os.chdir(path)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
os.chdir(before)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
|
||||
@@ -1170,10 +1170,13 @@ class FakeCorePasses(Workspace):
|
||||
c.host.run = timed
|
||||
passes.append(c)
|
||||
threads = [threading.Thread(target=c.run, args=(set(), None)) for c in passes]
|
||||
cwd = Path.cwd()
|
||||
for thread in threads:
|
||||
thread.start()
|
||||
for thread in threads:
|
||||
thread.join()
|
||||
# Each pass moved into its own root and back: the process ends where it began.
|
||||
self.assertEqual(Path.cwd(), cwd)
|
||||
ends = {name: sorted(end for _, end in runs) for name, runs in spans.items()}
|
||||
self.assertGreater(len(ends["a"]), 2)
|
||||
self.assertGreater(len(ends["b"]), 2)
|
||||
|
||||
Reference in new issue
Block a user