I am using PyCharm 4.0.5 with python 2.7.6 and the cassandra-driver library 2.5.0 and I am having trouble running code that calls Cluster.connect() from within the debugger *only* ie the same code works when using Run -> Run instead of Run -> Debug. The exception thrown is
NoHostAvailable: ('Unable to connect to any servers', {'127.0.0.1': OperationTimedOut('errors=None, last_host=None',)})
At first I thought maybe the control_connection_time (defaulted to 2) was being hit because code in the debugger runs slower but increasing only causes the process to wait for longer before timing out with the same message.
Looking around the driver code, I have been able to reproduce the problem outside it using the following example which seems equivalent to how the driver waits for a response when calling connection.register_watchers in cluster.py:1922
from threading import Thread, Event
event = Event()
class TestFoo(object):
def test_foo(self):
def runnable():
print('other thread starting')
event.set()
print('other thread called set')
t = Thread(target=runnable)
t.start()
print('main thread will wait')
event.wait(1000)
print('main thread woken up')
If I step through this in PyCharm in the debugger it will end up waiting for 1000 seconds but when I just run it it runs through immediately. I find it hard to believe the driver simply doesn't work in the debugger so any ideas are welcome! Thanks