Use datetimes
This commit is contained in:
parent
71d9e18eec
commit
8f5c4f3f0f
1 changed files with 10 additions and 8 deletions
|
@ -3,10 +3,11 @@ Modules that handles tor instaces creations in order to safely run histories
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
|
import datetime as dt
|
||||||
|
from time import sleep
|
||||||
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
|
||||||
|
|
||||||
|
@ -57,15 +58,16 @@ class TorInstance():
|
||||||
async def run(self):
|
async def run(self):
|
||||||
""" Runs the Tor Instance on the history.
|
""" Runs the Tor Instance on the history.
|
||||||
"""
|
"""
|
||||||
t_start = time.now()
|
while (self.history[0][1] - dt.datetime.now()).total_seconds >= 10:
|
||||||
while history:
|
print("Sleeping")
|
||||||
item = history.pop(0)
|
sleep(10)
|
||||||
|
while self.history:
|
||||||
|
item = self.history.pop(0)
|
||||||
async with async_timeout.timeout(30):
|
async with async_timeout.timeout(30):
|
||||||
await(self.query(item[0]))
|
await(self.query(item[0]))
|
||||||
t_end = time.now()
|
now = dt.datetime.now()
|
||||||
diff = (history[0][1] - item[0]) - (t_end - t_start)
|
if now <= self.history[0][1]:
|
||||||
if diff > 0:
|
sleep((self.history[0][1] - now).total_seconds())
|
||||||
sleep(diff)
|
|
||||||
|
|
||||||
|
|
||||||
def create_session(self):
|
def create_session(self):
|
||||||
|
|
Loading…
Reference in a new issue