Skip to content

Commit

Permalink
Merge pull request #183 from djmitche/issue182
Browse files Browse the repository at this point in the history
constructors cannot be async
  • Loading branch information
djmitche authored May 10, 2021
2 parents 458fdf0 + cf18729 commit 4ad59f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tcadmin/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ async def apply_changes(generated, current, grep):
resources=(r for r in current.resources if reg.search(r.id)),
)

updater = await Updater()
updater = await Updater.setup()
await updater.update(generated, current)
17 changes: 10 additions & 7 deletions tcadmin/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ class Updater:
A simple one-instance class to encapsulate shared Taskcluster API clients.
"""

async def __init__(self):
self.auth = Auth(await tcClientOptions(), session=aiohttp_session())
self.secrets = Secrets(await tcClientOptions(), session=aiohttp_session())
self.hooks = Hooks(await tcClientOptions(), session=aiohttp_session())
self.worker_manager = WorkerManager(
await tcClientOptions(), session=aiohttp_session()
)
@classmethod
async def setup(cls):
return cls(await tcClientOptions(), session=aiohttp_session())

def __init__(self, options, session):
"Use `Updater.create()` instead of calling this directly."
self.auth = Auth(options, session)
self.secrets = Secrets(options, session)
self.hooks = Hooks(options, session)
self.worker_manager = WorkerManager(options, session)

async def create_role(self, role):
await self.auth.createRole(role.roleId, role.to_api())
Expand Down

0 comments on commit 4ad59f8

Please sign in to comment.