2

I've just installed a base gentoo stage 3 and I get the following error when i try and call 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

I found this because when I try and run emerge I get:

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

This is a custom kernel and I just made sure I compiled in RTC support, but still no luck. Any ideas on why this is happening?

Burton Samograd
  • 3,652
  • 19
  • 21
  • Does this embedded gentoo system include `strace`? maybe `strace` a little python script that uses time.time() and see what syscall is erroring- that will give you an idea of where the issue resides. – tMC May 25 '11 at 19:21
  • No strace isn't included in the base install. Thought of that already. – Burton Samograd May 25 '11 at 19:51
  • whats the processor arch? Maybe we can compile the strace bin (statically if needed) and copy it to the host. I have a couple cross-compile chains if its helpful. – tMC May 25 '11 at 20:51

2 Answers2

3

Did it work before your custom kernel? Boot into a rescue CD, chroot into your gentoo env, and run your script. If it works, it's your kernel. That's about as specific as I can be.

Chris Eberle
  • 47,994
  • 12
  • 82
  • 119
  • It's an embedded system so I have to use a custom kernel. No option to boot any other way... – Burton Samograd May 25 '11 at 18:52
  • What kind of embedded system? Did you compile the correct timer module for it? – Chris Eberle May 25 '11 at 18:54
  • Also (this may not be the case for you), some embedded device manufacturers provide a linux kernel on their website. If yours does, try using that kernel. Gentoo shouldn't care, provided that it's a new enough kernel (I dunno, let's say 2.6.18 for funzies) – Chris Eberle May 25 '11 at 18:55
  • Custom board made by my company. Not sure about the timer driver, but I selected 'Generic RTC support'. That might be my problem; no driver possibly... – Burton Samograd May 25 '11 at 18:56
  • @Burton Samograd: If your company makes it, you might try asking around to see what type of clock is being used. Then check to see if the kernel supports that. – Chris Eberle May 25 '11 at 18:57
  • Just checked /proc/driver/rtc. It's there and it seems to be working ok with the time being updated every time i cat it. – Burton Samograd May 25 '11 at 18:58
  • `time.time()` uses the `gettimeofday` system call. I honestly don't know if this uses the RTC, my gut tells me it doesn't (and it just ate, so it knows what it's talking about). Compile a small test C program that calls off to `gettimeofday` and see what happens. – Chris Eberle May 25 '11 at 19:03
  • Of course that's another problem I'm having: when I try to compile with gcc i get: :0: internal compiler error: in ten_to_ptwo, at real.c:2246 – Burton Samograd May 25 '11 at 19:06
  • @Chris: Do you think i should? I just thought this would be a quicker route than using open embedded but so far its been nothing but problems... – Burton Samograd May 25 '11 at 19:08
0

Prehaps this is your issue ?

http://bugs.gentoo.org/show_bug.cgi?id=330937

edit C test code

#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);
}

If I compile this with gcc -DHAVE_GETTIMEOFDAY testtime.c I get a working time output, this is what python is boiling down to under the hood.

Maybe being on an embedded platform you need to convince python that your time function provided by the c library is wrong, or something is going awray in the kernel / C lib bits

Greg Bowyer
  • 1,684
  • 13
  • 14
  • No, doesn't look like it. This is a fresh install of stage3 just downloaded, so no problems with any upgrades. – Burton Samograd May 25 '11 at 18:48
  • I pulled down an autobuild so maybe that's the problem....i'm going to try 2008.0 (last available release) and see what that gets me. – Burton Samograd May 25 '11 at 19:13
  • How comfortable are you with C code ? ^^ I have extracted the python time functions above, you can compile that to see if it is something odd with your C library - You said you were working with an embedded install right, maybe its fudging up either the kernel bits or the C library bits – Greg Bowyer May 25 '11 at 19:17