我刚刚安装了一个基础gentoo阶段3,当我尝试调用time.time()时出现以下错误:
sbx / # python import time Python 2.7.1 (r271:86832, May 22 2011, 14:53:09) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> time.time() Traceback (most recent call last): File "", line 1, in IOError: [Errno 0] Error
我发现这是因为当我尝试运行emerge时,我得到:
sbx / # emerge Traceback (most recent call last): File "/usr/bin/emerge", line 32, in from _emerge.main import emerge_main File "/usr/lib/portage/pym/_emerge/main.py", line 6, in import logging File "/usr/lib/python2.7/logging/__init__.py", line 94, in _startTime = time.time() IOError: [Errno 11] Resource temporarily unavailable
这是一个自定义内核,我只是确保我在RTC支持中编译,但仍然没有运气。关于为什么会发生这种情况的任何想法?
答案 0 :(得分:3)
在自定义内核之前有效吗?启动到救援CD,chroot到你的gentoo环境,然后运行你的脚本。如果它有效,那就是你的内核。这和我一样具体。
答案 1 :(得分:0)
这可能是你的问题吗?
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);
}
如果我用gcc -DHAVE_GETTIMEOFDAY testtime.c
编译它,我会得到一个工作时间输出,这就是python正在深入研究的内容。
也许在嵌入式平台上你需要说服python你的c库提供的时间函数是错误的,或者某些内容在内核/ C lib位中出现错误