1818 import unittest # noqa
1919
2020from functools import partial
21+ import logging
2122from six .moves import range
2223import sys
2324import threading
2425from threading import Thread , Event
2526import time
27+ from unittest import SkipTest
2628
2729from cassandra import ConsistencyLevel , OperationTimedOut
2830from cassandra .cluster import NoHostAvailable , ConnectionShutdown , Cluster
4345 LibevConnection = None
4446
4547
48+ log = logging .getLogger (__name__ )
49+
50+
4651def setup_module ():
4752 use_singledc ()
4853
@@ -394,10 +399,14 @@ def test_connect_timeout(self):
394399 self .assertTrue (exception_thrown )
395400
396401 def test_subclasses_share_loop (self ):
397- class C1 (AsyncoreConnection ):
402+
403+ if self .klass not in (AsyncoreConnection , LibevConnection ):
404+ raise SkipTest
405+
406+ class C1 (self .klass ):
398407 pass
399408
400- class C2 (AsyncoreConnection ):
409+ class C2 (self . klass ):
401410 pass
402411
403412 clusterC1 = Cluster (connection_class = C1 )
@@ -412,16 +421,18 @@ class C2(AsyncoreConnection):
412421
413422
414423def get_eventloop_threads (name ):
415- import threading
416- event_loops_threads = [thread for thread in threading .enumerate () if name == thread .name ]
424+ all_threads = list (threading .enumerate ())
425+ log .debug ('all threads: {}' .format (all_threads ))
426+ log .debug ('all names: {}' .format ([thread .name for thread in all_threads ]))
427+ event_loops_threads = [thread for thread in all_threads if name == thread .name ]
417428
418429 return event_loops_threads
419430
420431
421432class AsyncoreConnectionTests (ConnectionTests , unittest .TestCase ):
422433
423434 klass = AsyncoreConnection
424- event_loop_name = "cassandra_driver_event_loop "
435+ event_loop_name = "asyncore_cassandra_driver_event_loop "
425436
426437 def setUp (self ):
427438 if is_monkey_patched ():
0 commit comments