Comments (5)
Think it's a good idea
from pyee.
what about:
Args = TypeVar(name="Args")
Kwargs = TypeVar(name="Kwargs")
@dataclass
class CoroError(PyeeError, Generic[Args, Kwargs]):
exc: Exception
handler: CoroHandler
args: Args
kwargs: Kwargs
def _emit_run(self, f: CoroHandler, args: Iterable[Args], kwargs: Dict[str, Kwargs]):
try:
coro = f(*args, **kwargs)
except Exception as exc:
self.emit("error",CoroError(exc=exc,handler=f,args=args, kwargs=kwargs)
from pyee.
what about:
@dataclass class AsyncIOPyeeError(PyeeError): exc: Exception handler: CoroHandler args: Tuple[Any,...] kwargs: Dict[str, Any] def _emit_run(self, f: CoroHandler, args: Iterable[Args], kwargs: Dict[str, Kwargs]): try: coro = f(*args, **kwargs) except Exception as exc: self.emit("error", AsyncIOPyeeError(exc=exc,handler=f,args=args, kwargs=kwargs)
Looks good, but i dont know why you need to use Protocol, didnt see it in other projects and dont know how it's works, but i will check it
from pyee.
Protocol might be a red herring, you can probably substitute Generic[Args, Kwargs]
instead. If you're not familiar with type annotations you can safely ignore them.
from pyee.
I took these notes and captured a plan for potential feature work in #102. In the meantime, I don't have any great answers aside from capturing Exceptions at the top of your handler "manually".
Thanks!
from pyee.
Related Issues (20)
- type-safe TypedEventEmitter implementation HOT 1
- Wrap captured exceptions in a PyeeError HOT 3
- [Regression]: EventEmitter.listeners("foo") throws if no listener exists HOT 2
- Regression: Docs on RTD are Broken HOT 1
- Automate RTD Build HOT 1
- Adopt pyproject.toml HOT 1
- Add .readthedocs.yaml HOT 1
- The 9.0.4 release in pypi isn't tagged in git HOT 2
- 9.0.4: pytest warnings HOT 5
- 9.0.4: sphinx warnings `reference target not found` HOT 6
- async lock error HOT 1
- AsyncIOEventEmitter should keep a reference to scheduled futures HOT 5
- "port of Node.js EventEmitter" not entirely accurate
- refactor EE import paths
- Handle for the async functions? HOT 4
- Using in Multiple Scripts HOT 1
- OSX Issue module 'select' has no attribute 'epoll' HOT 1
- Emit can be error HOT 1
- pyee release 9.0.x
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyee.