Repository: stable-diffusion-webui
Issue: [Bug]: Reload script (body only) does not work
Labels: bug-report

### Is there an existing issue for this?

- [X] I have searched the existing issues and checked the recent builds/commits

### What happened?

1. Reloading controlnet script throws an exception
2. (Filtered the controlnet script). After changing the custom script and clicking the reload script button, the script logic is not changed.

### Steps to reproduce the problem

1. Change a custom script code
2. Press "Reload script" button
3. Run the script again


### What should have happened?

1. No exception
2. The script run the new logic

### Commit where the problem happens

22bcc7be428c94e9408f589966c2040187245d81

### What platforms do you use to access the UI ?

Windows

### What browsers do you use to access the UI ?

Google Chrome

### Command Line Arguments

```Shell
NA
```


### List of extensions

ControlNet

### Console logs

```Shell
To create a public link, set `share=True` in `launch()`.
Startup time: 2.2s (list extensions: 0.7s, load scripts: 0.3s, create ui: 1.1s).
Traceback (most recent call last):
  File "F:\AI\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 337, in run_predict
    output = await app.get_blocks().process_api(
  File "F:\AI\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 1015, in process_api
    result = await self.call_function(
  File "F:\AI\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 833, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "F:\AI\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "F:\AI\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "F:\AI\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "F:\AI\stable-diffusion-webui\modules\ui.py", line 1515, in reload_scripts
    modules.scripts.reload_script_body_only()
  File "F:\AI\stable-diffusion-webui\modules\scripts.py", line 502, in reload_script_body_only
    cache = {}
  File "F:\AI\stable-diffusion-webui\modules\scripts.py", line 483, in reload_sources
    print(script.filename)
  File "F:\AI\stable-diffusion-webui\modules\script_loading.py", line 11, in load_module
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "F:\AI\stable-diffusion-webui\extensions\sd-webui-controlnet\scripts\controlnet.py", line 21, in <module>
    importlib.reload(global_state)
  File "E:\Python\3\lib\importlib\__init__.py", line 168, in reload
    raise ModuleNotFoundError(f"spec not found for the module {name!r}", name=name)
ModuleNotFoundError: spec not found for the module 'scripts.global_state'
```


### Additional information

I have no idea about the controlnet.py.

I try to fix the reloading bug by assigning the reloaded script to self.selectable_scripts[si] just after self.scripts[si].