# Running an async task with a timeout

**URL:** <https://forums.swift.org/t/running-an-async-task-with-a-timeout/49733>\
**Category:** Using Swift\
**Tags:** concurrency\
**Created:** [June 18, 2021, 11:58am UTC](https://forums.swift.org/t/running-an-async-task-with-a-timeout/49733 "2021-06-18T11:58:33Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Alejandro\_Martinez](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/alejandro_martinez/32/821_2.png) [@Alejandro\_Martinez](https://forums.swift.org/u/Alejandro_Martinez)\
**Post date:** [June 18, 2021, 9:37pm UTC](https://forums.swift.org/t/running-an-async-task-with-a-timeout/49733/5 "2021-06-18T21:37:28Z")

</div>

Very similar to what I [did](https://twitter.com/manuelmaly/status/1405995583794565137?s=21) and seems to be alright. The problem is that right now sleep doesn’t stop early when cancelled, which makes this a bit worthless.

I mentioned that in the structured concurrency review. [SE-0304 (3rd review): Structured Concurrency - #36 by Alejandro\_Martinez](https://forums.swift.org/t/se-0304-3rd-review-structured-concurrency/48847/36)

---

_[View the full topic](https://forums.swift.org/t/running-an-async-task-with-a-timeout/49733)._
