check accepted contact before sending request
This commit is contained in:
@@ -3,38 +3,7 @@ import threading
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
|
||||
class OnlyOne:
|
||||
class __OnlyOne:
|
||||
def __init__(self, arg):
|
||||
self.val = arg
|
||||
|
||||
def __str__(self):
|
||||
return repr(self) + self.val
|
||||
|
||||
instance = None
|
||||
|
||||
def __init__(self, arg):
|
||||
if not OnlyOne.instance:
|
||||
OnlyOne.instance = OnlyOne.__OnlyOne(arg)
|
||||
else:
|
||||
OnlyOne.instance.val = arg
|
||||
|
||||
def __getattr__(self, name):
|
||||
return getattr(self.instance, name)
|
||||
|
||||
|
||||
class TlsPlaywright():
|
||||
class TlsPlaywright(threading.local):
|
||||
# private nested inner class
|
||||
class __TlsPlaywrightSingleton(threading.local):
|
||||
def __init__(self) -> None:
|
||||
self.playwright = sync_playwright().start()
|
||||
print("创建浏览器实例,线程: ", threading.current_thread().name)
|
||||
|
||||
playwright = None
|
||||
|
||||
def __init__(self):
|
||||
if not TlsPlaywright.playwright:
|
||||
TlsPlaywright.playwright = TlsPlaywright.__TlsPlaywrightSingleton().playwright
|
||||
|
||||
def __getattr__(self, name):
|
||||
return getattr(self.playwright, name)
|
||||
def __init__(self) -> None:
|
||||
self.playwright = sync_playwright().start()
|
||||
|
||||
@@ -87,7 +87,7 @@ class CommandorPage:
|
||||
self.logger.info("will close timeout modem")
|
||||
self.termine()
|
||||
|
||||
def _run(self, e: threading.Event, proxy):
|
||||
def _run(self, proxy):
|
||||
self.logger.info("will start browser")
|
||||
self.on_success_listener = on_success
|
||||
# reset otp_value to None
|
||||
@@ -153,7 +153,7 @@ class CommandorPage:
|
||||
|
||||
def start_page(self, proxy):
|
||||
e = threading.Event()
|
||||
self._run(e, proxy)
|
||||
self._run(proxy)
|
||||
|
||||
def _on_page_loaded(self):
|
||||
self.logger.info("页面加载完毕")
|
||||
|
||||
Reference in New Issue
Block a user