Skip to content
This repository was archived by the owner on Sep 21, 2024. It is now read-only.

Automatically restart runtime #19

Merged
merged 2 commits into from
Jul 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ Colab notebooks created directly from Google Drive are tailored for Python progr
```swift
!curl "https://raw.githubusercontent.com/philipturner/swift-colab/release/latest/install_swift.sh" --output "install_swift.sh"
!bash "install_swift.sh" "5.6.2" #// Replace 5.6.2 with newest Swift version.
#// After this cell finishes, go to Runtime > Restart runtime.
#// Restart runtime.
import os
os.kill(os.getpid(), 9)
#// Expected warnings:
#// "Unrecognized runtime 'swift'; defaulting to 'python3'".
#// "Your session crashed. Automatically restarting".
#// "Your session restarted after a crash. Diagnosing..."
#// "Your session crashed for an unknown reason.""
```

> Tip: Colab measures how long you keep a notebook open without interacting with it. If you exceed the time limit of Colab's free tier, it may restart in Python mode. That means Swift code executes as if it's Python code. In that situation, repeat the process outlined above to return to Swift mode.
Expand Down