Skip to content
This repository was archived by the owner on Oct 24, 2020. It is now read-only.

Added capability to pass client session in API - #12

Open
hzlmn wants to merge 5 commits into
aio-libs-abandoned:masterfrom
hzlmn:share_session
Open

Added capability to pass client session in API#12
hzlmn wants to merge 5 commits into
aio-libs-abandoned:masterfrom
hzlmn:share_session

Conversation

@hzlmn

@hzlmn hzlmn commented Oct 4, 2018

Copy link
Copy Markdown

No description provided.

@hellysmile hellysmile left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What happens on close? Can session be closed multiple times?

Comment thread aioslacker/__init__.py Outdated
loop=self.loop,
),
)
if not isinstance(session, aiohttp.ClientSession):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This check makes no sense, as well can hard to debug, just remove this check, please.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if session is None, then create default session

Comment thread aioslacker/__init__.py Outdated
if not isinstance(session, aiohttp.ClientSession):
session = aiohttp.ClientSession(
connector=aiohttp.TCPConnector(
use_dns_cache=False,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can You remove use_dns_cache=False, as well, it is not needed anymore

Comment thread aioslacker/__init__.py Outdated

super().__init__(token=None, timeout=timeout, loop=loop)
super().__init__(
token=None, timeout=timeout, session=session, loop=loop

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can You place them one by one on each new line?

@hellysmile

Copy link
Copy Markdown
Collaborator

It seems, if session is custom we should not close it

@hellysmile

Copy link
Copy Markdown
Collaborator

Can we update upstream slacker dependency pin if we started to support custom sessions?

@hzlmn

hzlmn commented Oct 4, 2018

Copy link
Copy Markdown
Author

What happens on close? Can session be closed multiple times?

Yes, it will be closed only once.

It seems, if session is custom we should not close it

It is a good point, seems like most client libs like aioga , aiodocker close provided session anyway. But from user perspective i guess yes it will be more obvious not to close it.

Comment thread aioslacker/__init__.py Outdated

if session is None:
session = aiohttp.ClientSession(
connector=aiohttp.TCPConnector(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

connector is not needed here

@hzlmn

hzlmn commented Oct 18, 2018

Copy link
Copy Markdown
Author

@hellysmile

Can we update upstream slacker dependency pin if we started to support custom sessions?

Seems like yes, tested on example snippet and few others. Seems like works fine with legacy tokens.

@SirEdvin

Copy link
Copy Markdown

hey, can anyone can merge this?
it's annoying to call raw methods for thread slack API and reactions API, that don't work in old slacker version.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants