-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace requests get function to allow timeout #95
- Loading branch information
Herfort
committed
Mar 5, 2019
1 parent
cb2a092
commit 877dcfb
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import requests | ||
from mapswipe_workers.basic import BaseFunctions | ||
|
||
|
||
class myRequestsSession(requests.Session): | ||
|
||
def __init__(self): | ||
super(myRequestsSession, self).__init__() | ||
|
||
def get(self, request_ref, headers, timeout=30): | ||
print('Using customized get request with a timeout of 30 seconds.') | ||
return super(myRequestsSession, self).get(request_ref, headers=headers, timeout=timeout) | ||
|
||
|
||
def test_firebase_connection(): | ||
|
||
firebase, postgres = BaseFunctions.get_environment('development') | ||
fb_db = firebase.database() | ||
fb_db.requests.get = myRequestsSession().get | ||
|
||
|
||
request_object = fb_db.child("groups").child("1002").get().val() | ||
|
||
|
||
if __name__ == '__main__': | ||
test_firebase_connection() | ||
print("Everything passed") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters