Tor runner has a run function to replay the history
This commit is contained in:
parent
0a676a2f65
commit
f66c978466
1 changed files with 14 additions and 0 deletions
|
@ -6,6 +6,7 @@ import shutil
|
||||||
import asyncio
|
import asyncio
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from aiosocks.connector import ProxyConnector, ProxyClientRequest
|
from aiosocks.connector import ProxyConnector, ProxyClientRequest
|
||||||
|
from time import sleep
|
||||||
import async_timeout
|
import async_timeout
|
||||||
import stem.process as tor
|
import stem.process as tor
|
||||||
|
|
||||||
|
@ -51,6 +52,19 @@ class TorInstance():
|
||||||
self.session = None
|
self.session = None
|
||||||
self.process = None
|
self.process = None
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
""" Runs the Tor Instance on the history.
|
||||||
|
"""
|
||||||
|
t_start = time.now()
|
||||||
|
while history:
|
||||||
|
item = history.pop(0)
|
||||||
|
async with async_timeout.timeout(30):
|
||||||
|
await(self.query(item[0]))
|
||||||
|
t_end = time.now()
|
||||||
|
diff = (history[0][1] - item[0]) - (t_end - t_start)
|
||||||
|
if diff > 0
|
||||||
|
sleep(diff)
|
||||||
|
|
||||||
|
|
||||||
def create_session(self):
|
def create_session(self):
|
||||||
""" Create a aiohttp session.
|
""" Create a aiohttp session.
|
||||||
|
|
Loading…
Reference in a new issue