If I print the result of `handler.parsed_request()...
# general
r
If I print the result of
handler.parsed_request()
from the threads, I get:
Copy code
# The first thread
ENv is {'PANTSD_REQUEST_TIMEOUT_LIMIT': '-1'}
# The second thread
ENv is {}
a
is there a reason it's not like
self.mock_handler_inst.parsed_request.return_value = (None, None, [], fake_environment)
?
r
Yes
I didn’t know
.return_value
was a thing
Thanks, I’ll try that
a
mock is confusing to me and i tend to cargo cult things that work elsewhere in the repo
r
Still doesn’t work 😞
That’s been pretty much my strategy
a
what is
self.mock_handler_inst
?
r
An instance of
PailgunHandler
A mock of one
a
this is super confusing, i love it
is this in a PR?
r
Let me push the latest code
a
thanks!
r
pushed
a
will spend a moment checking it out
r
Thanks! Don’t spend too much though 🙂
a
me? never
i keep getting
AssertionError: 1 != 2
at
self.assertEqual(self.mock_handler_inst.handle_request.call_count, 2)
no matter how high i bump the
time.sleep()
right before
is that what you're getting right now too?
r
Do you also get
Copy code
Request <Mock id='140712395185904'> errored with 'PANTSD_REQUEST_TIMEOUT_LIMIT'
?
the 1 != 2 is expected if you see that error
a
omg i'm sorry
with you
yes i see that too
r
I have to leave 😞 I’ll read up on Mock’s documentation tomorrow. I’m also less and less suprised that we don’t have as many unit tests as we want. This framework is hard!
👍 1
Please don’t spend more time on this, it’s probably not worth it.
a
it doesn't appear there's any reason we're using
.pop()
. this diff caused it to pass for me:
Copy code
diff --git a/src/python/pants/pantsd/pailgun_server.py b/src/python/pants/pantsd/pailgun_server.py
index fd0c522..f768f22 100644
--- a/src/python/pants/pantsd/pailgun_server.py
+++ b/src/python/pants/pantsd/pailgun_server.py
@@ -209,7 +209,7 @@ class PailgunServer(ThreadingMixIn, TCPServer):
     """
     # TODO add `did_poll` to pantsd metrics

-    timeout = float(environment.pop('PANTSD_REQUEST_TIMEOUT_LIMIT'))
+    timeout = float(environment['PANTSD_REQUEST_TIMEOUT_LIMIT'])

     @contextmanager
     def yield_and_release(time_waited):
^ @red-balloon-89377
r
Omg
I'm not very smart right now, very good catch
Thanks!
a
np!!!