问题描述
|
我刚刚安装了基本的gentoo阶段3,尝试调用time.time()时收到以下错误:
sbx /#蟒蛇
导入时间
Python 2.7.1(r271:86832,2011年5月22日,14:53:09)
linux2上的[GCC 4.4.5]
键入\“ help \”,\“版权\”,\“信用\”或\“许可证\”以获取更多信息。
>>>导入时间
>>> time.time()
追溯(最近一次通话):
文件\“ \”,第1行,在
IOError:[Errno 0]错误
我发现这是因为尝试运行时会得到:
sbx /#出现
追溯(最近一次通话):
文件\“ / usr / bin / emerge \”,第32行,在
从_emerge.main导入emerge_main
文件\“ / usr / lib / portage / pym / _emerge / main.py \”,第6行
导入日志
文件\“ / usr / lib / python2.7 / logging / __ init __。py \”,第94行,在
_startTime = time.time()
IOError:[Errno 11]资源暂时不可用
这是一个自定义内核,我只是确保已在RTC支持下进行编译,但仍然没有运气。为什么会这样?
解决方法
它在您的自定义内核之前有效吗?引导至应急CD,将chroot插入gentoo env,然后运行脚本。如果可行,那就是您的内核。这大概是我所能做到的。
,也许这是你的问题?
http://bugs.gentoo.org/show_bug.cgi?id=330937
编辑C测试代码
#include <stdio.h>
#include <sys/time.h>
typedef struct timeval _PyTime_timeval;
void _PyTime_gettimeofday(_PyTime_timeval *tp)
{
/* There are three ways to get the time:
(1) gettimeofday() -- resolution in microseconds
(2) ftime() -- resolution in milliseconds
(3) time() -- resolution in seconds
In all cases the return value in a timeval struct.
Since on some systems (e.g. SCO ODT 3.0) gettimeofday() may
fail,so we fall back on ftime() or time().
Note: clock resolution does not imply clock accuracy! */
#ifdef HAVE_GETTIMEOFDAY
#ifdef GETTIMEOFDAY_NO_TZ
if (gettimeofday(tp) == 0)
return;
#else /* !GETTIMEOFDAY_NO_TZ */
if (gettimeofday(tp,(struct timezone *)NULL) == 0)
return;
#endif /* !GETTIMEOFDAY_NO_TZ */
#endif /* !HAVE_GETTIMEOFDAY */
#if defined(HAVE_FTIME)
{
struct timeb t;
ftime(&t);
tp->tv_sec = t.time;
tp->tv_usec = t.millitm * 1000;
}
#else /* !HAVE_FTIME */
tp->tv_sec = time(NULL);
tp->tv_usec = 0;
#endif /* !HAVE_FTIME */
return;
}
int main(int argc,char** argv) {
_PyTime_timeval time;
_PyTime_gettimeofday(&time);
double tval = 0;
tval = (double) time.tv_sec + time.tv_usec * 0.000001;
printf(\"Time value was %f\\n\",tval);
}
如果我用ѭ1进行编译,我会得到一个工作时间输出,这就是python逐渐深入到底层的原因。
也许在嵌入式平台上,您需要让python确信c库提供的时间函数是错误的,或者内核/ C lib位中的某些东西出了问题