jesper-raemaekers / python-polarion

A Python package to access the Polarion WSDL API.
MIT License
57 stars 35 forks source link

:sparkles: feat(Polarion Session object): reuse request session objec… #104

Closed MaxiGott closed 1 year ago

MaxiGott commented 1 year ago

:sparkles: feat(Polarion Session object): reuse request session object for soap interface

Added possibility to add a request session to the Polarion class arguments.

jesper-raemaekers commented 1 year ago

Hi MaxiGott,

I'm happy to approve this, just wondering what the use case is for this change?

-Jesper

MaxiGott commented 1 year ago

Hi Jesper, I would like to inject a retry strategy to to the zeep client. This can be done by a request session object like this:

import requests

from polarion import polarion
from requests.adapters import HTTPAdapter, Retry

# example of a retry strategy
my_sess = requests.Session()
retries = Retry(total=5,
                backoff_factor=0.1,
                status_forcelist=[ 500, 502, 503, 504 ])  # only retry those status codes

my_sess.mount('http://', HTTPAdapter(max_retries=retries)) # for all http connections

pol = polarion.Polarion(
                server = "<SOME_URL>", 
                user="<USER>"
                password="<PW>"
                request_session=s)

Thanks in advance! MaxiGott

jesper-raemaekers commented 1 year ago

Cool, I learned something new. Thanks!

MaxiGott commented 1 year ago

Thanks, and keep up your great work ! :)