https://pantsbuild.org/ logo
#general
Title
# general
r

red-balloon-89377

05/23/2019, 7:04 PM
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

aloof-angle-91616

05/23/2019, 7:05 PM
is there a reason it's not like
self.mock_handler_inst.parsed_request.return_value = (None, None, [], fake_environment)
?
r

red-balloon-89377

05/23/2019, 7:05 PM
Yes
I didn’t know
.return_value
was a thing
Thanks, I’ll try that
a

aloof-angle-91616

05/23/2019, 7:06 PM
mock is confusing to me and i tend to cargo cult things that work elsewhere in the repo
r

red-balloon-89377

05/23/2019, 7:06 PM
Still doesn’t work 😞
That’s been pretty much my strategy
a

aloof-angle-91616

05/23/2019, 7:06 PM
what is
self.mock_handler_inst
?
r

red-balloon-89377

05/23/2019, 7:06 PM
An instance of
PailgunHandler
A mock of one
a

aloof-angle-91616

05/23/2019, 7:07 PM
this is super confusing, i love it
is this in a PR?
r

red-balloon-89377

05/23/2019, 7:08 PM
Let me push the latest code
a

aloof-angle-91616

05/23/2019, 7:10 PM
thanks!
r

red-balloon-89377

05/23/2019, 7:12 PM
pushed
a

aloof-angle-91616

05/23/2019, 7:13 PM
will spend a moment checking it out
r

red-balloon-89377

05/23/2019, 7:14 PM
Thanks! Don’t spend too much though 🙂
a

aloof-angle-91616

05/23/2019, 7:19 PM
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

red-balloon-89377

05/23/2019, 7:25 PM
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

aloof-angle-91616

05/23/2019, 7:29 PM
omg i'm sorry
with you
yes i see that too
r

red-balloon-89377

05/23/2019, 7:32 PM
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

aloof-angle-91616

05/23/2019, 7:42 PM
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

red-balloon-89377

05/23/2019, 7:57 PM
Omg
I'm not very smart right now, very good catch
Thanks!
a

aloof-angle-91616

05/23/2019, 9:38 PM
np!!!