Comments (3)
Suggestion, wrap session object inside of method rather than the module. I believe that this would alleviate the problem.
def _request_token(client, payload):
session = requests.session()
session.headers.update({'user-agent': 'dwolla-v2-python %s' % version})
res = session.post(client.token_url, data=payload)
if _is_error(res):
raise Error.map(res)
token = client.Token(res.json())
if client.on_grant is not None:
client.on_grant(token)
return token
Current
session = requests.session()
session.headers.update({'user-agent': 'dwolla-v2-python %s' % version})
def _request_token(client, payload):
res = session.post(client.token_url, data=payload)
if _is_error(res):
raise Error.map(res)
token = client.Token(res.json())
if client.on_grant is not None:
client.on_grant(token)
return token
from dwolla-v2-python.
Hey @iteratelance, thanks for the detailed issue!
A while back we moved the session object to the module (#8) to take advantage of persistent connections and connection pooling.
Requests to www.dwolla.com
and api.dwolla.com
are handled in a similar way. Requests to www.dwolla.com
share a connection pool, whereas requests to api.dwolla.com
share a connection pool per-Token.
Does this SO issue sound like it could be what's happening? https://stackoverflow.com/questions/383738/104-connection-reset-by-peer-socket-error-or-when-does-closing-a-socket-resu/35945309#35945309
from dwolla-v2-python.
@sausman Thanks for the reply. I think it has something to do with AWS Lambda functions and how they operate. I've ran into this issue in the past when running async and threaded http request on Lambda and ultimately had to use a non threaded transport.
I'm not certain why connection polling has issues on Lambda, perhaps the underlying host might actually change from time to time, even while using a stay warm function for long running process, thus breaking the connection.
My final solution was to close the connection after getting each auth token.
from dwollav2 import auth
def auth():
client = dwollav2.Client(
key = config.get('DWOLLA_KEY'),
secret = config.get('DWOLLA_SECRET'),
environment = config.get('DWOLLA_ENV')
)
application_token = client.Auth.client()
auth.session.close()
return application_token
from dwolla-v2-python.
Related Issues (11)
- Allow verified_account flag to be provided when generating OAuth url
- Add Idempotency to requests
- pip install not working HOT 2
- Support for Cloudfare captcha HOT 1
- Client request timeout support
- Token URL Changes Not Released HOT 4
- Upload of document fails with TypeError in version 1.5.0 HOT 4
- readme.md link to Integrations Authorization Guide is broken HOT 1
- Using an expired Plaid token gets misleading error
- Sending multipart as describe in the README doesn't seem to work. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dwolla-v2-python.