Spaces:
Running
Running
File size: 767 Bytes
1a0cf07 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
from code_executor import PythonExecutor
import multiprocess
if __name__ == '__main__':
multiprocess.set_start_method('spawn')
current_code = """
```python
def calculate_hydrogen_mass(mass_of_water_grams):
mass_of_hydrogen = 1.00794 # g/mol
mass_of_water = 18.01528 # g/mol
ratio = (2 * mass_of_hydrogen) / mass_of_water
return ratio * mass_of_water_grams
mass_of_water = 23.5 # grams
hydrogen_mass = calculate_hydrogen_mass(mass_of_water)
print(hydrogen_mass)
```
"""
executor = PythonExecutor(get_answer_from_stdout=True)
result, report = executor.apply(current_code)
print("Result:", result)
print("Report:", report)
# Make sure to close the pool when done
executor.pool.close()
executor.pool.join()
|