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

Added capability to pass client session in API #12

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Added capability to pass client session in API #12

wants to merge 5 commits into from

Conversation

hzlmn
Copy link

@hzlmn hzlmn commented Oct 4, 2018

No description provided.

Copy link
Collaborator

@hellysmile hellysmile left a comment

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?

loop=self.loop,
),
)
if not isinstance(session, aiohttp.ClientSession):
Copy link
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
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

if not isinstance(session, aiohttp.ClientSession):
session = aiohttp.ClientSession(
connector=aiohttp.TCPConnector(
use_dns_cache=False,
Copy link
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

*, loop=None
):
self.url = url

super().__init__(token=None, timeout=timeout, loop=loop)
super().__init__(
token=None, timeout=timeout, session=session, loop=loop
Copy link
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
Collaborator

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

@hellysmile
Copy link
Collaborator

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

@hzlmn
Copy link
Author

hzlmn commented Oct 4, 2018

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.

if not isinstance(session, aiohttp.ClientSession):
self._close_session = False

if session is None:
session = aiohttp.ClientSession(
connector=aiohttp.TCPConnector(
Copy link
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
Copy link
Author

hzlmn commented Oct 18, 2018

@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

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