Debugger exits abruptly with timeout error

  • 3
  • 6

Cannot attach debugger to unit test. The debugging session stops abrutply wit timeout error in about 5 seconds.


File "/Applications/PyCharm.app/helpers/pydev/pydevd_frame.py", line 34, in doWaitSuspend
self._args[0].doWaitSuspend(*args, **kwargs)
File "/Applications/PyCharm.app/helpers/pydev/pydevd.py", line 838, in doWaitSuspend
time.sleep(0.01)
File "/Users/swagle/Documents/workspace/ambari/ambari-server/src/test/python/TestAmbaryServer.py", line 1108, in signal_handler
self.fail("Timed out!")
AssertionError: Timed out!
The timeout error is thrown from your code:
"...TestAmbaryServer.py", line 1108, in signal_handler

Could you please attach the contents of the signal_handler function?
--
Dmitry Jemerov, Chief Technology Officer, JetBrains

Hi Dmitry,

Thank you for responding. Here is the link to the unit test code,
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/python/TestAmbaryServer.py?view=markup&pathrev=1493290

The exception belongs to one of the unit tests, although it

Unit test with signal_handler:

@patch.object(ambari_server, "setup_db")
@patch.object(ambari_server, "print_info_msg")
@patch.object(ambari_server, "run_os_command")
@patch.object(ambari_server, "parse_properties_file")
@patch.object(ambari_server, "is_root")
def test_silent_reset(self, is_root_mock, parse_properties_file_mock,
run_os_command_mock, print_info_msg_mock,
setup_db_mock):
is_root_mock.return_value = True

args = MagicMock()
ambari_server.SILENT = True
self.assertTrue(ambari_server.SILENT)
run_os_command_mock.return_value = (0, None, None)

def signal_handler(signum, frame):
self.fail("Timed out!")

signal.signal(signal.SIGALRM, signal_handler)
signal.alarm(5)
rcode = ambari_server.reset(args)

self.assertEqual(None, rcode)
self.assertTrue(setup_db_mock.called)



Best Regard,
Sid














































On Mon, Jun 17, 2013 at 3:44 AM, Dmitry Jemerov - PyCharm <
jetforum@jetbrains.com> wrote:

* PyCharm <http://forum.jetbrains.com/forum/PyCharm> * > * Debugger exits
abruptly with timeout error<http://forum.jetbrains.com/thread/PyCharm-1544>
* 6:44 am<http://forum.jetbrains.com/thread/PyCharm-1544?message=PyCharm-1544-1> Dmitry
Jemerov <http://forum.jetbrains.com/user/yole>

The timeout error is thrown from your code:
"...TestAmbaryServer.py", line 1108, in signal_handler

Could you please attach the contents of the signal_handler function?



Dmitry Jemerov, Chief Technology Officer, JetBrains

Sid <http://forum.jetbrains.com/user/Sid> @ Jun 14<http://forum.jetbrains.com/thread/PyCharm-1544>

Cannot attach debugger to unit test. The debugging session stops abrutply
wit timeout error in about 5 seconds.


File "/Applications/PyCharm.app/helpers/pydev/pydevd_frame.py", line 34,
in doWaitSuspend
self._args[0].doWaitSuspend(*args, **kwargs)
File "/Applications/PyCharm.app/helpers/pydev/pydevd.py", line 838, in
doWaitSuspend
time.sleep(0.01)
File
"/Users/swagle/Documents/workspace/ambari/ambari-server/src/test/python/TestAmbaryServer.py",
line 1108, in signal_handler
self.fail("Timed out!")
AssertionError: Timed out!

JetBrains Forum | Build #171 (Jun/07/2013 10:26AM) | Feedback<http://confluence.jetbrains.net/display/JETF/Feedback>

Well, your test sets an alarm and aborts execution if it doesn't complete in 5 seconds. Of course it can take longer than 5 seconds if you run it under a debugger and stop on a breakpoint. You need to remove or disable the timeout alarm when running under a debugger.
--
Dmitry Jemerov, Chief Technology Officer, JetBrains