Eel | little Python library for making simple Electron
kandi X-RAY | Eel Summary
kandi X-RAY | Eel Summary
Eel is a little Python library for making simple Electron-like offline HTML/JS GUI apps, with full access to Python capabilities and libraries. Eel hosts a local webserver, then lets you annotate functions in Python so that they can be called from Javascript, and vice versa. Eel is designed to take the hassle out of writing short and simple GUI applications. If you are familiar with Python and web development, probably just jump to this example which picks random file names out of the given folder (something that is impossible from a browser).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Start the client .
- Start the development server .
- Process a message .
- Initialize javascript functions .
- Open a starting page .
- Create a websocket connection .
- Find the chrome extension .
- Expose a function .
- Render a static file .
- Return a function that returns a callback function .
Eel Key Features
Eel Examples and Code Snippets
imageSource = Sitegeist.Kaleidoscope:DummyImageSource
renderer = afx`
`
imageSource = Sitegeist.Kaleidoscope:DummyImageSource
renderer = afx`
`
imageSource = Sitegeist.Kaleidoscope:DummyImageSource
@eel.expose
def my_python_function(a, b):
print(a, b, a + b)
console.log("Calling Python...");
eel.my_python_function(1, 2); // This calls the Python function that was decorated
eel.expose(my_javascript_function);
function my_javascript_funct
import eel
eel.init('web')
def my_other_thread():
while True:
print("I'm a thread")
eel.sleep(1.0) # Use eel.sleep(), not time.sleep()
eel.spawn(my_other_thread)
eel.start('main.html', block=False) # Don't
Community Discussions
Trending Discussions on Eel
QUESTION
Per [intro.object]/2:
[..] An object that is not a subobject of any other object is called a complete object [..].
So consider this snippet of code:
...ANSWER
Answered 2022-Mar-21 at 00:32- An object is not a class.
- An object is an instantiation of a class, an array, or built-in-type.
- Subobjects are class member objects, array elements, or base classes of an object.
- Derived objects (and most-derived objects) only make sense in the context of class inheritance.
QUESTION
Consider this example
...ANSWER
Answered 2022-Feb-22 at 07:03Yes, as of now, the One Definition Rule in the C++ standard doesn't include enumerators.
However, the "the second a
is a redeclaration of the first a
" explanation doesn't work too.
From [dcl.enum#nt:enumerator-list] we can know that an enumerator-list is a list of enumerator-definition, so they're all definitions.
QUESTION
Discussion about this was started under this answer for quite simple question.
ProblemThis simple code has unexpected overload resolution of constructor for std::basic_string
:
ANSWER
Answered 2022-Jan-05 at 12:05Maybe I'm wrong, but it seems that last part:
QUESTION
A quote from the standard regarding std::basic_string_view
equality comparison operators (see http://eel.is/c++draft/string.view#comparison):
...[Example 1: A sample conforming implementation for operator== would be:
ANSWER
Answered 2022-Jan-25 at 15:13I think this is insufficient reduction as a result of the adoption of <=>
in P1614. Before that paper, there were three ==
s in the example:
QUESTION
struct X { int n; };
const X *p = new const X{3}; // #1
new (const_cast(p)) const X{5}; // #2
const int c = std::launder(p)->n;
...ANSWER
Answered 2022-Jan-17 at 18:46[basic.compound]/3 is not relevant. It specifically says that it applies only for the purpose of pointer arithmetic and comparison. There doesn't actually exist an array for the object.
I think when you call std::launder
, there are four objects at the relevant address: obj1
, obj1.n
, obj2
and obj2.n
.
obj1
and obj1.n
are pointer-interconvertible, as are obj2
and obj2.n
. Other combinations aside from identical pairs, are not pointer-interconvertible. There are no array objects and therefore "or the immediately-enclosing array object if Z is an array element." isn't relevant.
When considering reachability from std::launder(p)
, which points to obj2
thus only obj2
and obj2.n
need to be considered as Z
in the quote. obj2.n
occupies an (improper) subset of bytes of obj2
, so it is not relevant. The bytes reachable are those in obj2
. Except that I considered obj2.n
specifically, this is a rephrasing of your considerations.
By exactly the same reasoning, the bytes reachable from p
(pointing to obj1
) are all those in obj1
.
obj1
and obj2
have the same size and therefore occupy exactly the same bytes. Therefore std::launder(p)
would not make any bytes reachable that aren't reachable from p
.
QUESTION
I'm trying to understand the purpose of std::atomic_thread_fence(std::memory_order_seq_cst);
fences, and how they're different from acq_rel
fences.
So far my understanding is that the only difference is that seq-cst fences affect the global order of seq-cst operations ([atomics.order]/4
). And said order can only be observed if you actually perform seq-cst loads.
So I'm thinking that if I have no seq-cst loads, then I can replace all my seq-cst fences with acq-rel fences without changing the behavior. Is that correct?
And if that's correct, why am I seeing code like this "implementation Dekker's algorithm with Fences", that uses seq-cst fences, while keeping all atomic reads/writes relaxed? Here's the code from that blog post:
...ANSWER
Answered 2022-Jan-06 at 05:14As I understand it, they're not the same, and a counterexample is below. I believe the error in your logic is here:
And said order can only be observed if you actually perform seq-cst loads.
I don't think that's true. In atomics.order p4 which defines the
axioms of the sequential consistency total order S, items 2-4 all may
involve operations which are not seq_cst
. You can observe the
coherence ordering between such operations, and this can let you infer
how the seq_cst
operations have been ordered.
As an example, consider the following version of the StoreLoad litmus test, akin to Peterson's algorithm:
QUESTION
The standard defines several 'happens before' relations that extend the good old 'sequenced before' over multiple threads:
[intro.races]
11 An evaluation A simply happens before an evaluation B if either
(11.1) — A is sequenced before B, or
(11.2) — A synchronizes with B, or
(11.3) — A simply happens before X and X simply happens before B.[Note 10: In the absence of consume operations, the happens before and simply happens before relations are identical. — end note]
12 An evaluation A strongly happens before an evaluation D if, either
(12.1) — A is sequenced before D, or
(12.2) — A synchronizes with D, and both A and D are sequentially consistent atomic operations ([atomics.order]), or
(12.3) — there are evaluations B and C such that A is sequenced before B, B simply happens before C, and C is sequenced before D, or
(12.4) — there is an evaluation B such that A strongly happens before B, and B strongly happens before D.[Note 11: Informally, if A strongly happens before B, then A appears to be evaluated before B in all contexts. Strongly happens before excludes consume operations. — end note]
(bold mine)
The difference between the two seems very subtle. 'Strongly happens before' is never true for matching pairs or release-acquire operations (unless both are seq-cst), but it still respects release-acquire syncronization in a way, since operations sequenced before a release 'strongly happen before' the operations sequenced after the matching acquire.
Why does this difference matter?
'Strongly happens before' was introduced in C++20, and pre-C++20, 'simply happens before' used to be called 'strongly happens before'. Why was it introduced?
[atomics.order]/4
says that the total order of all seq-cst operations is consistent with 'strongly happens before'.
Does it mean that it's not consistent with 'simply happens before'? If so, why not?
I'm ignoring the plain 'happens before', because it differs from 'simply happens before' only in its handling of memory_order_consume
, the use of which is temporarily discouraged, since apparently most (all?) major compilers treat it as memory_order_acquire
.
I've already seen this Q&A, but it doesn't explain why 'strongly happens before' exists, and doesn't fully address what it means (it just states that it doesn't respect release-acquire syncronization, which isn't completely the case).
Found the proposal that introduced 'simply happens before'.
I don't fully understand it, but it explains following:
- 'Strongly happens before' is a weakened version of 'simply happens before'.
- The difference is only observable when seq-cst is mixed with aqc-rel on the same variable (I think, it means when an acquire load reads a value from a seq-cst store, or when an seq-cst load reads a value from a release store). But the exact effects of mixing the two are still unclear to me.
ANSWER
Answered 2022-Jan-02 at 18:21Here's my current understanding, which could be incomplete or incorrect. A verification would be appreciated.
C++20 renamed strongly happens before
to simply happens before
, and introduced a new, more relaxed definition for strongly happens before
, which imposes less ordering.
Simply happens before
is used to reason about the presence of data races in your code. (Actually that would be the plain 'happens before', but the two are equivalent in absence of consume operations, the use of which is discouraged by the standard, since most (all?) major compilers treat them as acquires.)
The weaker strongly happens before
is used to reason about the global order of seq-cst operations.
This change was introduced in proposal P0668R5: Revising the C++ memory model, which is based on the paper Repairing Sequential Consistency in C/C++11 by Lahav et al (which I didn't fully read).
The proposal explains why the change was made. Long story short, the way most compilers implement atomics on Power and ARM architectures turned out to be non-conformant in rare edge cases, and fixing the compilers had a performance cost, so they fixed the standard instead.
The change only affects you if you mix seq-cst operations with acquire-release operations on the same atomic variable (i.e. if an acquire operation reads a value from a seq-cst store, or a seq-cst operation reads a value from a release store).
If you don't mix operations in this manner, then you're not affected (i.e. can treat simply happens before
and strongly happens before
as equivalent).
The gist of the change is that the synchronization between a seq-cst operation and the corresponding acquire/release operation no longer affects the position of this specific seq-cst operation in the global seq-cst order, but the synchronization itself is still there.
This makes the seq-cst order for such seq-cst operations very moot, see below.
The proposal presents following example, and I'll try to explain my understanding of it:
QUESTION
Some ranges adaptors such as filter_view
, take_while_view
and transform_view
use std::optional
's cousin copyable-box
to store the callable object:
ANSWER
Answered 2021-Oct-09 at 14:20All the algorithms require copy-constructible function objects, and views are basically lazy algorithms.
Historically, when these adaptors were added, views were required to be copyable
, so we required the function objects to be copy_constructible
(we couldn't require copyable
without ruling out captureful lambdas). The change to make view
only require movable
came later.
It is probably possible to relax the restriction, but it will need a paper and isn't really high priority.
QUESTION
[...] It is a standard-layout class ([class.prop]).
What is the reason for this requirement?
...ANSWER
Answered 2021-Nov-03 at 15:11Interoperability with the associated C interface. From N2320 (Multi-threading Library for Standard C++):
The C level interface has been removed from this proposal with the following rationale:
- As long as we specify that the key types in this proposal are standard-layout types (which we have done), WG14 is still free to standardize a C interface which interoperates with this C++ interface.
- WG14 is in a better position to solve the cancellation interoperability problem than WG21 is. [...]
- WG14 asked WG21 to take the lead on this issue. We feel we can best take lead by specifying only a C++ interface which has the minimum hooks in it to support a future C interoperating interface (i.e. types are standard-layout types). We feel we should stop short of actually specifying that C interface in the C++ standard. WG14 can do a better job with the C interface and a future C++ standard can then import it by reference.
QUESTION
Consider this code:
...ANSWER
Answered 2021-Nov-01 at 21:47Yes, I think we can prove that a == 1 || b == 1
is always true. Most of the ideas here were worked out in comments by zwhconst and Peter Cordes, so I just thought I would write it up as an exercise.
(Note that X, Y, A, B below are used as the dummy variables in the standard's axioms, and may change from line to line. They do not coincide with the labels in your code.)
Suppose b = x.load()
in thread2 yields 0.
We do have the coherence ordering that you asked about. Specifically, if b = x.load
yields 0, then I claim that x.load()
in thread2 is coherence ordered before x.store(1)
in thread1, thanks to the third bullet in the definition of coherence ordering. For let A be x.load()
, B be x.store(1)
, and X be the initialization x{0}
(see below for quibble). Clearly X precedes B in the modification order of x
, since X happens-before B (synchronization occurs when the thread is started), and if b == 0
then A has read the value stored by X.
(There is possibly a gap here: initialization of an atomic object is not an atomic operation (3.18.1p3), so as worded, the coherence ordering does not apply to it. I have to believe it was intended to apply here, though. Anyway, we could dodge the issue by putting x.store(0, std::memory_order_relaxed);
in main
before starting the threads, which would still address the spirit of your question.)
Now in the definition of the ordering S, apply the second bullet with A = x.load()
and B = x.store(1)
as before, and Y being the atomic_thread_fence
in thread1. Then A is coherence-ordered before B, as we just showed; A is seq_cst
; and B happens-before Y by sequencing. So therefore A = x.load()
precedes Y = fence
in the order S.
Now suppose a = y.load()
in thread1 also yields 0.
By a similar argument to before, y.load()
is coherence ordered before y.store(1)
, and they are both seq_cst
, so y.load()
precedes y.store(1)
in S. Also, y.store(1)
precedes x.load()
in S by sequencing, and likewise atomic_thread_fence
precedes y.load()
in S. We therefore have in S:
x.load
precedesfence
precedesy.load
precedesy.store
precedesx.load
which is a cycle, contradicting the strict ordering of S.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Eel
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page