# Canister Lifecycle Hooks

**URL:** <https://forum.dfinity.org/t/canister-lifecycle-hooks/17089>\
**Category:** Developers\
**Tags:** Discussing, community-consideration\
**Created:** [December 5, 2022, 8:10pm UTC](https://forum.dfinity.org/t/canister-lifecycle-hooks/17089 "2022-12-05T20:10:44Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![dansteren](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dansteren/32/1048_2.png) [@dansteren](https://forum.dfinity.org/u/dansteren)\
**Post date:** [December 7, 2022, 6:22pm UTC](https://forum.dfinity.org/t/canister-lifecycle-hooks/17089/11 "2022-12-07T18:22:52Z")

</div>

> Does this limitation greatly reduce usefulness of `canister_post_init()` ?

Yes. I think the driving motivation behind a `canister_post_init()` hook (or whatever we end up naming it) is **specifically** to await cross-canister calls. If you just want to execute non-async code I’d imagine you would just add it to your `init()` or `postUpgrade()` methods. It’s specifically the async stuff that we’re trying to provide a handle for.

To provide a concrete use case, consider the need to seed custom randomness. This requires making a cross-canister call to the management canister’s `raw_rand()` method. You’d most assuredly want that to complete before you attempted to use random in your other canister methods. If other methods start getting hit before the randomness is fully seeded it could cause significant problems.

Seeding randomness is just one example. I imagine there will be many scenarios where external data is needed to get a canister into the correct start state.

Furthermore, when asking about how to guarantee async code happens before other messages, the [currently accepted solution](https://forum.dfinity.org/t/cross-canister-compatible-post-init-hook/16929/4) is to add a guard clause inside each update method. I see the `canister_post_init()` hook as the replacement to those initialization guards, so I think it must provide the same level of assurance.

---

_[View the full topic](https://forum.dfinity.org/t/canister-lifecycle-hooks/17089)._
