Skip to content
This repository has been archived by the owner on Sep 11, 2019. It is now read-only.

inconsistent behavior for jumpscale python installation #803

Open
Hamdy opened this issue Aug 22, 2019 · 0 comments
Open

inconsistent behavior for jumpscale python installation #803

Hamdy opened this issue Aug 22, 2019 · 0 comments

Comments

@Hamdy
Copy link
Contributor

Hamdy commented Aug 22, 2019

The following code works fine on my host machine (no jumpscale) python 3.6.7

Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: def add(a, b): 
   ...:     return a + b 
   ...:                                                                                              

In [2]: import inspect                                                                               

In [3]: inspect.getsource(add)                                                                       
Out[3]: 'def add(a, b):\n    return a + b\n'

The same code does not work on jumpscale on python3, ptpython , nor kosmos

JSX> import inspect                                                                                  
JSX> def add(a, b): 
   2     return a + b                                                                                
JSX> inspect.getsource(add)                                                                          
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/inspect.py", line 973, in getsource
    lines, lnum = getsourcelines(object)
  File "/usr/lib/python3.6/inspect.py", line 955, in getsourcelines
    lines, lnum = findsource(object)
  File "/usr/lib/python3.6/inspect.py", line 786, in findsource
    raise OSError('could not get source code')
OSError: could not get source code

could not get source code

why this is important? because it affects calling j.servers.myjobs.schedule from kosmos

JSX> def add(a, b):return a + b                                                                      
JSX> j.servers.myjobs.schedule(add, 1,2)Thu 22 09:27:33 InstallTools.py      -1688 - execute                            : execute:whoami
                                        Thu 22 09:27:33 InstallTools.py      -1688 - execute                            : execute:cat /proc/1/cgroup
JSX> j.servers.myjobs.schedule(add, 1,2)                                                             
executing method add with *args (1, 2) and **kwargs {} 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/sandbox/lib/jumpscale/DigitalMe/servers/myjobs/MyJobs.py", line 384, in schedule
    code = inspect.getsource(method)
  File "/usr/lib/python3.6/inspect.py", line 973, in getsource
    lines, lnum = getsourcelines(object)
  File "/usr/lib/python3.6/inspect.py", line 955, in getsourcelines
    lines, lnum = findsource(object)
  File "/usr/lib/python3.6/inspect.py", line 786, in findsource
    raise OSError('could not get source code')
OSError: could not get source code

could not get source code
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant