Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #103521

Looking for examples of using aiopg with aiohttp and non-async startup.

From Ray Cote <rgacote@appropriatesolutions.com>
Newsgroups comp.lang.python
Subject Looking for examples of using aiopg with aiohttp and non-async startup.
Date 2016-02-25 17:23 -0500
Message-ID <mailman.136.1456439065.20994.python-list@python.org> (permalink)

Show all headers | View raw


Hello:

I have an aiohttp project that starts in the usual way:

app = web.Application()
app.router.add_route(‘POST”, ‘/‘, handler)
web.run_app(app)

My question is, how do I work with an aiopg.pool with aiohttp?
There only seems to be async interfaces into aiopg — but I don’t want to
create the pool in my handler since that requires a connection on each
transaction.

I found one example that was
  app[“db”] = await aiopg.create_pool(dsn)
but that doesn’t seen correct since we’re not yet in a loop.

Can someone please provide an example showing the proper way to integrate
aiopg pool into an aiohttp web application?

Regards
—Ray

-- 
Raymond Cote, President
voice: +1.603.924.6079 email: rgacote@AppropriateSolutions.com skype:
ray.cote

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Looking for examples of using aiopg with aiohttp and non-async startup. Ray Cote <rgacote@appropriatesolutions.com> - 2016-02-25 17:23 -0500

csiph-web