kylebarron / stata_kernel

A Jupyter kernel for Stata. Works with Windows, macOS, and Linux.
https://kylebarron.dev/stata_kernel/
GNU General Public License v3.0
266 stars 57 forks source link

Sessions assume exclusive access to files in cache_directory, breaking simultaneous sessions #405

Closed ryan-wallace-frbb closed 2 years ago

ryan-wallace-frbb commented 3 years ago

Problem description

Issue arises when a user runs two or more stata_kernel sessions simultaneously with the same cache_directory path configured. The stata_kernel uses the same include.do file in the cache_dir directory for both sessions. This leads to a race condition between sessions in writing to and reading/executing from include.do.

The effect is intermittent, seemingly inexplicable Stata errors resulting from Stata executing code run from a different session.

Code Sample

To reproduce, run multiple simultaneous sessions. Easiest to reproduce when the notebooks for each session have multiple cells that may start near-simultaneously.

Expected Output

No Stata errors.

Other information