Whenever I enable HTTPretty, I'm unable to make a connection with PyMongo. I know that HTTPretty alters the core socket module; is there any way around this?
Code Example:
import pymongo
import httpretty
import time
httpretty.enable()
try:
client = pymongo.MongoClient()
except pymongo.errors.AutoReconnect:
print("AutoReconnect")
time.sleep(2)
Raises exception:
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\pymongo\mongo_client.py", line 363, in __init__
self._ensure_connected(True)
File "C:\Python33\lib\site-packages\pymongo\mongo_client.py", line 924, in _ensure_connected
self.__ensure_member()
File "C:\Python33\lib\site-packages\pymongo\mongo_client.py", line 797, in __ensure_member
member, nodes = self.__find_node()
File "C:\Python33\lib\site-packages\pymongo\mongo_client.py", line 888, in __find_node
raise AutoReconnect(', '.join(errors))
pymongo.errors.AutoReconnect: [WinError 10035] A non-blocking socket operation could not be completed immediately
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tmp.py", line 7, in
client = pymongo.MongoClient()
File "C:\Python33\lib\site-packages\pymongo\mongo_client.py", line 366, in __init__
raise ConnectionFailure(str(e))
pymongo.errors.ConnectionFailure: [WinError 10035] A non-blocking socket operation could not be completed immediately
I am on Windows 8.1 using Python 3.3.
Can anyone explain this behavior and how to resolve it? Thanks!