Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HELpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
HELpy
Commits
6e89a3eb
Commit
6e89a3eb
authored
2 months ago
by
Krzysztof Mochocki
Browse files
Options
Downloads
Patches
Plain Diff
Add session to RequestCommunicator
parent
49842d18
No related branches found
No related tags found
1 merge request
!73
Clive integration related fixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
helpy/helpy/_communication/request_communicator.py
+13
-2
13 additions, 2 deletions
helpy/helpy/_communication/request_communicator.py
with
13 additions
and
2 deletions
helpy/helpy/_communication/request_communicator.py
+
13
−
2
View file @
6e89a3eb
from
__future__
import
annotations
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
,
Any
import
requests
...
...
@@ -10,6 +10,7 @@ from helpy._communication.abc.communicator import (
from
helpy.exceptions
import
CommunicationError
if
TYPE_CHECKING
:
from
helpy._communication.settings
import
CommunicationSettings
from
helpy._interfaces.stopwatch
import
StopwatchResult
from
helpy._interfaces.url
import
HttpUrl
...
...
@@ -17,16 +18,26 @@ if TYPE_CHECKING:
class
RequestCommunicator
(
AbstractCommunicator
):
"""
Provides support for requests library (only synchronous).
"""
def
__init__
(
self
,
*
args
:
Any
,
settings
:
CommunicationSettings
,
**
kwargs
:
Any
)
->
None
:
super
().
__init__
(
*
args
,
settings
=
settings
,
**
kwargs
)
self
.
__session
:
requests
.
Session
|
None
=
None
async
def
_async_send
(
self
,
url
:
HttpUrl
,
data
:
bytes
,
stopwatch
:
StopwatchResult
)
->
str
:
raise
NotImplementedError
@property
def
session
(
self
)
->
requests
.
Session
:
if
self
.
__session
is
None
:
self
.
__session
=
requests
.
Session
()
return
self
.
__session
def
_send
(
self
,
url
:
HttpUrl
,
data
:
bytes
,
stopwatch
:
StopwatchResult
)
->
str
:
last_exception
:
BaseException
|
None
=
None
amount_of_retries
=
0
while
not
self
.
_is_amount_of_retries_exceeded
(
amount
=
amount_of_retries
):
amount_of_retries
+=
1
try
:
response
:
requests
.
Response
=
requests
.
post
(
response
:
requests
.
Response
=
self
.
session
.
post
(
url
.
as_string
(),
data
=
data
,
headers
=
self
.
_json_headers
(),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment