[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Dropping the _get_pid() helper from stem.process
commit f40ab20110a1979efbffaa7854eca5ff77a5e9c3
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Wed Mar 6 19:56:57 2013 -0800
Dropping the _get_pid() helper from stem.process
Huh, that's odd. There's a comment saying that I tried to use the mocking
module for os.getpid() but it was a no-go, necessitating an ugly hack. I just
tried again and it worked - maybe a bug we have since fixed with the mocking?
---
stem/process.py | 6 +-----
test/integ/process.py | 6 +-----
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/stem/process.py b/stem/process.py
index 4c7d118..e21b077 100644
--- a/stem/process.py
+++ b/stem/process.py
@@ -98,7 +98,7 @@ def launch_tor(tor_cmd = "tor", args = None, torrc_path = None, completion_perce
runtime_args += ["-f", torrc_path]
if take_ownership:
- runtime_args += ["__OwningControllerProcess", _get_pid()]
+ runtime_args += ["__OwningControllerProcess", str(os.getpid())]
tor_process = subprocess.Popen(runtime_args, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
@@ -241,7 +241,3 @@ def launch_tor_with_config(config, tor_cmd = "tor", completion_percent = 100, in
os.remove(torrc_path)
except:
pass
-
-
-def _get_pid():
- return str(os.getpid())
diff --git a/test/integ/process.py b/test/integ/process.py
index a65a24b..59663f3 100644
--- a/test/integ/process.py
+++ b/test/integ/process.py
@@ -116,12 +116,8 @@ class TestProcess(unittest.TestCase):
elif test.runner.require_version(self, stem.version.Requirement.TAKEOWNERSHIP):
return
- # Have os.getpid provide the pid of a process we can safely kill. I hate
- # needing to a _get_pid() helper but after much head scratching I haven't
- # been able to mock os.getpid() or posix.getpid().
-
sleep_process = subprocess.Popen(['sleep', '60'])
- mocking.mock(stem.process._get_pid, mocking.return_value(str(sleep_process.pid)))
+ mocking.mock(os.getpid, mocking.return_value(str(sleep_process.pid)), target_module = os)
tor_process = stem.process.launch_tor_with_config(
tor_cmd = test.runner.get_runner().get_tor_command(),
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits