Resolves issue #5 for now
This commit is contained in:
parent
ca9ab0401d
commit
d1d1a39a30
3 changed files with 20 additions and 4 deletions
10
main.py
10
main.py
|
@ -45,7 +45,14 @@ def loadUrl(url):
|
|||
|
||||
headers = { 'User-Agent': 'Monutil monitor' }
|
||||
|
||||
response = requests.get(url, timeout=config.urlTimeout, headers=headers)
|
||||
@retry(stop_max_attempt_number=3)
|
||||
def submitRequest(url):
|
||||
|
||||
response = requests.get(url, timeout=config.urlTimeout, headers=headers)
|
||||
return response
|
||||
|
||||
response = submitRequest(url)
|
||||
|
||||
return response
|
||||
|
||||
def prepareUrl(src, baseUrl):
|
||||
|
@ -233,6 +240,7 @@ if __name__ == "__main__":
|
|||
import threading
|
||||
import signal
|
||||
import socket
|
||||
from retrying import retry
|
||||
from functools import partial
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from bs4 import BeautifulSoup
|
||||
|
|
13
rabbitmq.py
13
rabbitmq.py
|
@ -28,6 +28,7 @@ import base64
|
|||
import config
|
||||
import log
|
||||
import datetime
|
||||
from retrying import retry
|
||||
|
||||
class rabbitMQClient:
|
||||
|
||||
|
@ -42,6 +43,13 @@ class rabbitMQClient:
|
|||
|
||||
def publish(self, message):
|
||||
|
||||
@retry(stop_max_attempt_number=3)
|
||||
def publishMessage(conn):
|
||||
|
||||
ch = conn.channel()
|
||||
|
||||
ch.basic_publish(exchange='', routing_key=self.routingKey, body=message, properties=pika.BasicProperties(delivery_mode=pika.spec.PERSISTENT_DELIVERY_MODE))
|
||||
|
||||
message = base64.b64encode(message.encode('utf-8'))
|
||||
|
||||
context = ssl.create_default_context(
|
||||
|
@ -55,10 +63,9 @@ class rabbitMQClient:
|
|||
|
||||
with pika.BlockingConnection(connParams) as conn:
|
||||
|
||||
ch = conn.channel()
|
||||
|
||||
ch.basic_publish(exchange='', routing_key=self.routingKey, body=message, properties=pika.BasicProperties(delivery_mode=pika.spec.PERSISTENT_DELIVERY_MODE))
|
||||
publishMessage(conn)
|
||||
|
||||
@retry(stop_max_attempt_number=3)
|
||||
def retrieve(self):
|
||||
|
||||
def callback(ch, method, properties, body):
|
||||
|
|
|
@ -2,3 +2,4 @@ psutil
|
|||
requests
|
||||
bs4
|
||||
datetime
|
||||
retrying
|
||||
|
|
Loading…
Reference in a new issue