question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How thread safe are promises?

See original GitHub issue

After reading through the source for some time I do not see any use of locks (like the imported and ignored from threading import RLock) to protect one thread adding a callback to a promise instance from another thread that is resolving/rejecting that promise…

So is such use of a promise invalid or does it work because of the GIL? … or something else?

Thanks for the awesome code!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
chrothcommented, Dec 18, 2018

@PepperTeasdale It sounds like your issue is related to https://github.com/syrusakbary/promise/issues/57

0reactions
syrusakbarycommented, Dec 18, 2019

The PR #81 has been merged. Promises should be now thread-safe in Promise 2.3.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is std::promise<T> thread-safe? - c++ - Stack Overflow
1. So calling get_future from multiple threads doesn't really make sense from a practical point of view. There is no guarantee for thread-safety...
Read more >
Is Combine Future's promise thread… | Apple Developer Forums
Yes, Future is thread safe. Escaping parameters like that out of a block might result easily in leaks, but should still work. Posted...
Read more >
std::promise - cppreference.com
This example shows how promise<int> can be used as signals between threads. Run this code. #include <vector> #include <thread> #include <future> ...
Read more >
A thread-safe typed Promise implementation in Java for Android
I've created a typed Promise implementation in Java for Android, borrowing ideas from this article for a JavaScript implementation, by Forbes ...
Read more >
Multithreading in C++ - Modern C++ Concurrency - Educative.io
Tasks are like data channels between two communication endpoints. They enable thread-safe communication between threads: the promise at one endpoint puts data ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found