Skip to main content

ipython-bg

  1. Use %bg to run line in background
  2. Use %%bg to run cell in background
  3. Use %jobs to view all background jobs
  4. Use %kill to try to kill a thread - only works if thread runs python code

How to load extension

In [1]: %load_ext ipython_bg

%bg - run line in background

In [2]: %bg run_this_command_in_background = 1
[1] running in background

[job completed] run_this_command_...

%%bg - run cell in background

In [3]: %%bg 
   ...: run_this_cell_in_background = 1 
   ...: more_lines = "yes, more lines." 
   ...:  
   ...:

[2] running in background

[job completed] run_this_cell_in_...

%jobs - view all background jobs

In [4]: %jobs
jobs:
[1] start=22:49:50, code=run_this_command_..., completed, finished=22:49:50, took=0:0
[2] start=22:50:13, code=run_this_cell_in_..., completed, finished=22:50:13, took=0:0

In [5]: print(run_this_command_in_background, run_this_cell_in_background, more_lines)
1 1 yes, more lines.

%kill - try to kill a thread

In [6]: %%bg 
   ...: import time 
   ...: time.sleep(5) 
   ...: print("this won't be printed :(") 
   ...: time.sleep(100000) 
   ...:

[3] running in background

In [7]: %kill 3
[job killed] import time...
Exception in thread Thread-4:
Traceback (most recent call last):
  File "/Users/drorspei/.pyenv/versions/3.6.10/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/Users/drorspei/.pyenv/versions/3.6.10/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/drorspei/src/ipython-bg/ipython_bg/__init__.py", line 19, in runjob
    exec(code, ipython.user_ns)
  File "<string>", line 2, in <module>
KeyboardInterrupt

Metadata

Release files for ipython-bg 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ipython-bg 0.2
File Size Uploaded Provenance Actions
ipython-bg-0.2.tar.gz 2.9 kB Without provenance Details for ipython-bg-0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ipython-bg 0.2
File Interpreter ABI Platform Actions
ipython_bg-0.2-py3-none-any.whl Python 3 none any Details for ipython_bg-0.2-py3-none-any.whl

Total release size: 6.7 kB

Release files / ipython-bg-0.2.tar.gz

Download URL ipython-bg-0.2.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
88c67bd3a2d6556a2b19d43ed078c79d722cf7805b3af30c4dd71b366d6ba603
BLAKE2b-256 checksum
How to use checksums
fed92b20dc374ba1a164ecfb34757216387425e00dccd574a16ea0d754a174a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

Release files / ipython_bg-0.2-py3-none-any.whl

Download URL ipython_bg-0.2-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c269b438c05eda6d83fd0ee29602ebf5de3a6c7af10527500c367261a5eb795
BLAKE2b-256 checksum
How to use checksums
f0cd5c76edf2f40816ca442e32d6348fd142c2dd94a59a29da2600c5b80d5549
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.10

Security for ipython-bg 0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page