Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket97 loop arg #98

Merged
merged 8 commits into from
Apr 8, 2017
Merged

Ticket97 loop arg #98

merged 8 commits into from
Apr 8, 2017

Conversation

meejah
Copy link
Contributor

@meejah meejah commented Apr 6, 2017

Okay here's how it looks for having "an API object". Sorry the diffs are huge -- but most of it is re-indenting.

The upshot is: we add one new public method ("with_config()" I've called it for now) and all existing code will work as-is. Anyone wanting "multiple custom configs" (which is only "loop" arg anyway) changes their code. So if you have code like:

import txaio

class Foo(object):

    def something_async(self):
        return txaio.create_future()

Then you change it to look like this:

import txaio

class Foo(object):
    txa = txaio

    def something_async(self):
        return self.txa.create_future()

...and if you wanted a custom loop in Foo, then you set foo.txa = txaio.with_config(loop=custom_loop) and you're good. So essentially a two-step way to "buy in" to the custom-loop API:

  1. search-replace all txaio.* calls with "self.obj.*" and set a class-attibute "obj = txaio".
  2. Then for instances that need a custom loop, you replace their obj attribute.

Very open to suggestions for the "with_config" method-name!

@codecov-io
Copy link

codecov-io commented Apr 6, 2017

Codecov Report

Merging #98 into master will increase coverage by 0.05%.
The diff coverage is 96.52%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #98      +/-   ##
==========================================
+ Coverage    95.7%   95.76%   +0.05%     
==========================================
  Files           9        9              
  Lines         628      684      +56     
==========================================
+ Hits          601      655      +54     
- Misses         27       29       +2
Impacted Files Coverage Δ
txaio/__init__.py 94.11% <100%> (ø) ⬆️
txaio/_common.py 98.41% <100%> (+0.02%) ⬆️
txaio/_unframework.py 96.96% <100%> (+0.09%) ⬆️
txaio/tx.py 95.74% <93.51%> (-0.38%) ⬇️
txaio/aio.py 99.54% <99.15%> (+0.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e33f12e...c8d6513. Read the comment docs.

@oberstet oberstet merged commit b2df90f into crossbario:master Apr 8, 2017
@oberstet
Copy link
Contributor

oberstet commented Apr 8, 2017

Looks good! Cool.

Guess only thing missing:

  • docs
  • probably and example (asyncio with multiple loop)

Rgd docs, actually 3 levels?

  1. on user code change at all: works as today, using default loop
  2. user adds class variable (or instance variable) - preparation
  3. user sets explicit loop

@meejah meejah deleted the ticket97-loop-arg branch April 9, 2017 02:47
This was referenced Apr 29, 2017
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.

None yet

3 participants