The full documentation for socketcan can be found in the kernel docs at
networking/can.txt.
The CAN network driver provides a generic
interface to setup, configure and monitor CAN devices. To configure
bit-timing parameters use the program ip.

vcan should be substituted for can and vcan0 should be
substituted for can0 if you are using real hardware. Setting the
bitrate can also be done at the same time, for example to enable an
existing can0 interface with a bitrate of 1MB:

A device may enter the “bus-off” state if too many errors occurred on
the CAN bus. Then no more messages are received or sent. An automatic
bus-off recovery can be enabled by setting the “restart-ms” to a
non-zero value, e.g.:

sudo ip link set canX type can restart-ms 100

Alternatively, the application may realize the “bus-off” condition by
monitoring CAN error frames and do a restart when appropriate with the
command:

If you set the timeout to 0.0, the read will be executed as non-blocking,
which means bus.recv(0.0) will return immediately, either with a Message
object or None, depending on whether data was available on the socket.