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

Wherefore callbacks? #70

Open
habemus-papadum opened this issue Jul 13, 2018 · 3 comments
Open

Wherefore callbacks? #70

habemus-papadum opened this issue Jul 13, 2018 · 3 comments

Comments

@habemus-papadum
Copy link

Hi,
the current design uses callbacks to communicate the results of operations back to the fuse daemon, e.g.: the cb in readdir: function (path, cb) ....

Can you explain the rationale for this, rather than, say having the operations return values e.g.

readdir: function (path) { return ['file1'];}

The python bindings for fuse seems to choose that approach.

For instance is it ever correct to call a callback more than once for a given operation? Also can a callback be used after the operation notification has completed? (e.g. readdir returns without calling cb, and at a later point cb is called with proper data)

A 'yes' to either question would clarify the current design, however, best would be examples demonstrating the possibilities.

Cheers! nehal

@piranna
Copy link
Contributor

piranna commented Jul 13, 2018

Python is a blocking language, while Javascript not, so operations are asynchronous. They work the same way, only that in Python the execution will stop until the called functions return a value, and in Javascript they continue, so instead of returning the result, you pass it to the callback function.

@habemus-papadum
Copy link
Author

python learned async/await a while back and has known yield for a very long time....

But, to keep it simple -- is it valid to cb more than once for any operation?

@piranna
Copy link
Contributor

piranna commented Jul 13, 2018

But, to keep it simple -- is it valid to cb more than once for any operation?

Depends of the library you are using, but usually (like in this case) not.

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

No branches or pull requests

2 participants