@@ -441,7 +441,13 @@ def reconnect(self, timeout=0.1):
441
441
with suppress (Exception ):
442
442
if self .service .is_connectable ():
443
443
self .stop_client ()
444
- self .service .stop ()
444
+ try :
445
+ self .service .send_remote_shutdown_command ()
446
+ except TypeError :
447
+ pass
448
+ finally :
449
+ with suppress (Exception ):
450
+ self .service ._terminate_process ()
445
451
if isinstance (timeout , str ):
446
452
if timeout .lower () == "breakpoint" :
447
453
breakpoint () # To continue:
@@ -466,7 +472,13 @@ def reconnect(self, timeout=0.1):
466
472
self .close ()
467
473
if self .service .is_connectable ():
468
474
self .stop_client ()
469
- self .service .stop ()
475
+ try :
476
+ self .service .send_remote_shutdown_command ()
477
+ except TypeError :
478
+ pass
479
+ finally :
480
+ with suppress (Exception ):
481
+ self .service ._terminate_process ()
470
482
self .service .start ()
471
483
self .start_session ()
472
484
time .sleep (0.003 )
@@ -482,7 +494,13 @@ def disconnect(self):
482
494
if self .service .is_connectable ():
483
495
self .stop_client ()
484
496
time .sleep (0.003 )
485
- self .service .stop ()
497
+ try :
498
+ self .service .send_remote_shutdown_command ()
499
+ except TypeError :
500
+ pass
501
+ finally :
502
+ with suppress (Exception ):
503
+ self .service ._terminate_process ()
486
504
self ._is_connected = False
487
505
488
506
def connect (self ):
@@ -507,7 +525,13 @@ def connect(self):
507
525
self .close ()
508
526
if self .service .is_connectable ():
509
527
self .stop_client ()
510
- self .service .stop ()
528
+ try :
529
+ self .service .send_remote_shutdown_command ()
530
+ except TypeError :
531
+ pass
532
+ finally :
533
+ with suppress (Exception ):
534
+ self .service ._terminate_process ()
511
535
self .service .start ()
512
536
self .start_session ()
513
537
time .sleep (0.003 )
@@ -539,7 +563,13 @@ def quit(self):
539
563
logger .debug ("Stopping webdriver service" )
540
564
with suppress (Exception ):
541
565
self .stop_client ()
542
- self .service .stop ()
566
+ try :
567
+ self .service .send_remote_shutdown_command ()
568
+ except TypeError :
569
+ pass
570
+ finally :
571
+ with suppress (Exception ):
572
+ self .service ._terminate_process ()
543
573
with suppress (Exception ):
544
574
if self .reactor and isinstance (self .reactor , Reactor ):
545
575
logger .debug ("Shutting down Reactor" )
0 commit comments