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

OAuth expiry of token will hang fastapi server #3150

Closed
skaark opened this issue Apr 30, 2024 · 1 comment
Closed

OAuth expiry of token will hang fastapi server #3150

skaark opened this issue Apr 30, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@skaark
Copy link

skaark commented Apr 30, 2024

There is a deadlock situation in sdk/python/packages/flet/src/flet/fastapi/flet_app_manager.py
The following code is locked with a non-recursive lock.

async def __evict_expired_oauth_states(self):
        while True:
            await asyncio.sleep(10)
            with self.__states_lock:
                ids = []
                for id, state in self.__states.items():
                    if (
                        state.expires_at
                        and datetime.now(timezone.utc) > state.expires_at
                    ):
                        ids.append(id)
                for id in ids:
                    logger.info(f"Delete expired oauth state: {id}")
                    self.retrieve_state(id)

However, the self.retrieve_state(id) call locks the code again. As the lock is non-recursive, the code dead-locks at this point. You need to either make the lock recursive(RLock() instead of Lock()), or create an internal unprotected version of retrieve_state, which can be called under locking from the public retrieve_state.

@FeodorFitsner FeodorFitsner added the bug Something isn't working label May 3, 2024
@FeodorFitsner
Copy link
Contributor

Good catch, thanks!

50Bytes-dev pushed a commit to 50Bytes-dev/flet that referenced this issue May 18, 2024
* Fix `flet --version` command for source checkout

* Fix message

* update `file_picker` to 8.0.3

* Added logo in png

* Added `--exclude` option to `flet build` command

Close flet-dev#3125

* Flet version bumped to 0.22.1

* Fixed: OAuth expiry of token will hang fastapi server

Fix flet-dev#3150

* Update changelog

* Make `dependency_overrides` optional

Fix flet-dev#3187

* Updated changelog
zrr1999 pushed a commit to zrr1999/flet that referenced this issue Jul 17, 2024
* Fix `flet --version` command for source checkout

* Fix message

* update `file_picker` to 8.0.3

* Added logo in png

* Added `--exclude` option to `flet build` command

Close flet-dev#3125

* Flet version bumped to 0.22.1

* Fixed: OAuth expiry of token will hang fastapi server

Fix flet-dev#3150

* Update changelog

* Make `dependency_overrides` optional

Fix flet-dev#3187

* Updated changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants