Comments (3)
See also #135
from pywlroots.
Hi @heuer, thanks for the feedback here! The rationale I had for raising an exception here rather than using a return code is channeling Raymond Hettinger's "Beyond PEP 8" PyCon talk, in that we have more naturally suited tools in Python for reporting and handling errors than the underlying C library than return codes. Ensuring return codes are always checked in all clients is more error prone, and if there is clean-up that needs to be done on failure we can encapsulate that here for every use case rather than needing to have that repeated everywhere. Certainly if there are things that we are doing in the attempted clean-up that wouldn't necessarily be the thing that we want to always have happen we can go about changing that.
That said, I'm sure there are cases where return codes would come in handy. In the cases you mention, what would be the benefit of having the return code rather than the exception?
from pywlroots.
Thanks for your reply. Acc. to my understanding all applications have to catch the exception since a wayland.Display was already created which have to be destroyed as well:
try:
server.backend.start()
except RuntimeError as ex:
# backend was destroyed already, more cleanup necessary
server.display.destroy()
raise ex
If Backend.start() just returns a boolean value, it would lead to more, at least in my opinion, elegant code which communicates the intention better.
if not server.backend.start():
server.backend.destroy()
server.display.destroy()
raise RuntimeException("Problem starting backend")
And it would be closer to the wlroots API. At least the fact that the backend tries to destroy itself in case of an error was very surprising for me.
from pywlroots.
Related Issues (20)
- Proposal: Add helper function ptr_or_null to wlroots.__init__.py
- pywlr 0.16.x: xdg_shell.XdgTopLevel: "base" property is not implemented HOT 1
- Remove exception from SceneOutput.commit: Should return boolean
- fatal error: xkbcommon/xkbcommon.h: No such file or directory. HOT 8
- Check usage of context managers HOT 2
- OutputHeadV1State: Invalid custom_mode setter
- Pointer: Missing data property
- Avoid usage of deprecated surface module
- Touch: Missing data property
- pywlroots wheel contains unnecessary libs HOT 4
- XdgTopLevel: Incorrect check of the pointer, a parent is always returned
- Release 0.16.8 HOT 1
- Seat.touch_point_clear_focus: Wrong signature: Takes too many arguments
- Support for wlr_tablet_tool HOT 3
- WLR 0.17 - Proposal: Rename XdgTopLevel to XdgToplevel HOT 1
- Inconsistencies with setters and getters HOT 13
- Release 0.16.9 HOT 2
- Renderer: autocreate() checks for a truth value not for ffi.NULL
- Future API improvements HOT 2
- Issue building qtile wheels when with xkbcommon=1.0 HOT 1
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 pywlroots.