Skip to content

Added async support - #134

Closed
Werded wants to merge 3 commits into
GetStream:mainfrom
Werded:main
Closed

Added async support#134
Werded wants to merge 3 commits into
GetStream:mainfrom
Werded:main

Conversation

@Werded

@Werded Werded commented Jan 15, 2022

Copy link
Copy Markdown

Summary:

Submitter checklist:

  • CHANGELOG updated or N/A
  • Documentation updated or N/A

Merger checklist:

  • ALL tests have passed
  • Code Review is done
  • Dependencies satisfied

Dependencies:

@Werded
Werded requested a review from ferhatelmas as a code owner January 15, 2022 16:01
@ferhatelmas

Copy link
Copy Markdown
Contributor

Amazing, thanks for the PR 👍🏻 Could you rebase your PR please?

@ferhatelmas
ferhatelmas requested a review from peterdeme January 18, 2022 23:08
@Werded

Werded commented Jan 19, 2022

Copy link
Copy Markdown
Author

Amazing, thanks for the PR 👍🏻 Could you rebase your PR please?

done

Comment thread stream/__init__.py Outdated
__credits__ = ["Thierry Schellenbach, mellowmorning.com, @tschellenbach"]
__license__ = "BSD-3-Clause"
__version__ = "5.1.1"
__version__ = "6.0.0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to change this, we'll bump it when we release it

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread CHANGELOG.md Outdated
Comment on lines +1 to +5
## 6.0.0 - 2021-01-19

* Add asynchronous code support
* Change ``%s`` to f-strings

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add this, we'll add it when we release it

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

) as response:

logger.debug(
f"stream api call {response}, headers {headers} data {data}",

@peterdeme peterdeme Jan 21, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't leak the JWT into the logs. Can we either remove headers or filter out Authorization header?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed Authorization from headers

Comment thread stream/client/async_client.py Outdated
Comment on lines +244 to +245
timeout=self.timeout,
verify_ssl=False,

@peterdeme peterdeme Jan 21, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verify ssl must be true.

Suggested change
timeout=self.timeout,
verify_ssl=False,
timeout=self.timeout,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread stream/client/async_client.py Outdated
base_url=base_url,
location=location,
)
self.session = aiohttp.ClientSession

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need session variable at all. Why not just:

        async with aiohttp.ClientSession() as session:
            async with session.request(

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Comment thread stream/client/client.py
params=default_params,
timeout=self.timeout,
)
logger.debug(f"stream api call {response.url}, headers {headers} data {data}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we leak the jwt here as well.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread stream/tests/test_client.py Outdated
Comment on lines +36 to +37
key = os.environ["STREAM_KEY"]
secret = os.environ["STREAM_SECRET"]
key = "n8udba92h9hf"
secret = "5mjaw2a5bynt3fzdnxy2pwxh7fw89gg2dq3mm4jy56vhrwnadfst7yssatmaxhkv"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread stream/tests/conftest.py Outdated
Comment on lines +26 to +27
key = "n8udba92h9hf"
secret = "5mjaw2a5bynt3fzdnxy2pwxh7fw89gg2dq3mm4jy56vhrwnadfst7yssatmaxhkv"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

sys.exit(1)

return stream.connect(key, secret, location="qa", timeout=30)
return stream.connect(key, secret, location="qa", timeout=30, use_async=use_async)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a future improvement client could be a fixture instead of a global variable :)

@peterdeme

Copy link
Copy Markdown
Contributor

Will try to merge it!

@peterdeme

Copy link
Copy Markdown
Contributor

@Werded I opened a new PR with your commits, please follow this one: #135

@peterdeme peterdeme closed this Feb 2, 2022
@ferhatelmas ferhatelmas reopened this Feb 3, 2022
@ferhatelmas ferhatelmas closed this Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants