From bb00201aafae4ece55fa106b852ddea1b88a3e5f Mon Sep 17 00:00:00 2001 From: Hannah Ward Date: Thu, 16 Feb 2017 15:23:42 +0000 Subject: [PATCH] new: Added base async imports --- pymisp/api.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pymisp/api.py b/pymisp/api.py index faedd40..6f6169f 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -82,7 +82,7 @@ class PyMISP(object): threat_level = threat_level analysis = analysis - def __init__(self, url, key, ssl=True, out_type='json', debug=False, proxies=None, cert=None): + def __init__(self, url, key, ssl=True, out_type='json', debug=False, proxies=None, cert=None, asynch=False): if not url: raise NoURL('Please provide the URL of your MISP instance.') if not key: @@ -93,6 +93,15 @@ class PyMISP(object): self.ssl = ssl self.proxies = proxies self.cert = cert + self.asynch = asynch + if self.asynch: + try: + from requests_futures.sessions import FuturesSession + except ImportError: + print("You set Async, but you haven't got requests_futures installed") + print("Reverting to synchronous") + self.asynch = False + self.ressources_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data') if out_type != 'json': raise PyMISPError('The only output type supported by PyMISP is JSON. If you still rely on XML, use PyMISP v2.4.49')