Get the hardware address as a 48-bit positive integer. The first time this runs, it may launch a separate program, which could be quite slow. If all attempts to obtain the hardware address fail, we choose a random 48-bit number with its eighth bit set to 1 as recommended in RFC 412
()
| 700 | _node = None |
| 701 | |
| 702 | def getnode(): |
| 703 | """Get the hardware address as a 48-bit positive integer. |
| 704 | |
| 705 | The first time this runs, it may launch a separate program, which could |
| 706 | be quite slow. If all attempts to obtain the hardware address fail, we |
| 707 | choose a random 48-bit number with its eighth bit set to 1 as recommended |
| 708 | in RFC 4122. |
| 709 | """ |
| 710 | global _node |
| 711 | if _node is not None: |
| 712 | return _node |
| 713 | |
| 714 | for getter in _GETTERS + [_random_getnode]: |
| 715 | try: |
| 716 | _node = getter() |
| 717 | except: |
| 718 | continue |
| 719 | if (_node is not None) and (0 <= _node < (1 << 48)): |
| 720 | return _node |
| 721 | assert False, '_random_getnode() returned invalid value: {}'.format(_node) |
| 722 | |
| 723 | |
| 724 | _last_timestamp = None |