2

我刚刚安装了一个基本的 gentoo stage 3,当我尝试调用 time.time() 时出现以下错误:

sbx / # 蟒蛇
进口时间
Python 2.7.1(r271:86832,2011 年 5 月 22 日,14:53:09)
[GCC 4.4.5] 在 linux2 上
输入“帮助”、“版权”、“信用”或“许可”以获取更多信息。
>>> 进口时间
>>> 时间.时间()
回溯(最近一次通话最后):
  文件“”,第 1 行,在
IOError:[Errno 0] 错误

我发现这是因为当我尝试运行emerge时,我得到:

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 支持中编译,但仍然没有运气。关于为什么会发生这种情况的任何想法?

4

2 回答 2

3

它在您的自定义内核之前有效吗?启动到救援 CD,chroot 进入您的 gentoo 环境,然后运行您的脚本。如果它有效,那就是你的内核。这是我所能做到的最具体的。

于 2011-05-25T18:51:16.643 回答
0

Prehaps这是你的问题?

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 库位中出现问题

于 2011-05-25T18:42:59.693 回答