Skyscanner / aiotask-context

Contextual information for asyncio tasks
MIT License
161 stars 25 forks source link

Get and Set methods are still usable without registering the task #4

Closed pfreixes closed 7 years ago

pfreixes commented 7 years ago

This commits helps us to give some backward compatibility if the task factory hans't been registered the context attribute is created on the fly instead of failing.

If the loop is not started it is still failing.

argaen commented 7 years ago

Giving a second though, I'm not sure this is 100% the behavior we want. We are adding is so we don't break previous versions but:

In case of ensure_futures when there is no task factory, context won't exist. This means it will be created on demand but anything will be propagated for different Task objects. This means that for calls like that, the context will be being lost without crashing which I don't know if its the expected behavior (I know, there is the warning but still...)

pfreixes commented 7 years ago

Yes, context won't be propagated in these scenarios. And yes, this MR would make the code kinda inconsistent.

pfreixes commented 7 years ago

Closing it lets implementing the backward compatibility layer in the caller module.