# Is there a way to know whether no objects out of \`if \_\_name\_\_=="\_\_main\_\_"\`

**URL:** <https://discourse.jupyter.org/t/is-there-a-way-to-know-whether-no-objects-out-of-if-name-main/7865>\
**Category:** Notebook\
**Created:** [February 9, 2021, 1:40pm UTC](https://discourse.jupyter.org/t/is-there-a-way-to-know-whether-no-objects-out-of-if-name-main/7865 "2021-02-09T13:40:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mszhanyi](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mszhanyi/32/3697_2.png) [@mszhanyi](https://discourse.jupyter.org/u/mszhanyi)\
**Post date:** [February 9, 2021, 1:40pm UTC](https://discourse.jupyter.org/t/is-there-a-way-to-know-whether-no-objects-out-of-if-name-main/7865/1 "2021-02-09T13:40:12Z")

</div>

Hi, experts  
As we know, main module in spawned processes is an empty module in fact. So, python multiprocessing fails in notebook on Windows in general, unless the code is like below, that is, not codes between imports and `if __name__ == " __main__"`

`import XXX`  
`import YYY`  
`from ZZZ import dosomething`  
`if __name__ == " __main__":`  
`dosomething()`

Is there an elegant way to know this situation? Thus, dosomething() can spawn new processes without exception.
