How to run ios tests in parallel (ruby lib)?

I read that theres a way (although its not ‘official’) to run ios tests in parallel. You have to stat appium in defferent ports and tempfile (https://github.com/appium/appium/issues/273)

I am using ruby client, when i run (i use rakefile) it starts on one device, then when it will starts on another, the first process is killed. should I run it on different thread?

caps.default = {
        platformName: 'iOS',
        deviceName: get_device_name,
        app: app_ipa,
        launchTimeout: 100000,
        autoAcceptAlerts: false,
        newCommandTimeout: 12000,
        udid: get_udid,
        fullReset: false,
        # bootstrapPort: 6001
    }

def teste
    port = 5678
    get_udids.each { |device|
      port += 1
      #i start appium server usind different ports for each real device
      run_appium_service(port)

      start_appium_driver(udid: device.serial_number, appium_lib: port)
    }
  end

def run_appium_service(port)
...
    Process.fork { system "appium --log-level debug -p #{port} > tmp-#{port}/appium.log" } 
end

def start_appium_driver(options={})
...
Appium::Driver.new(caps: capabilities, appium_lib: {port: options[:port]})
end

Here is the appium log of the first session that is started, when another starts (hope im clear enough and this is not the full log, just the end of it)

[Appium] New IosDriver session created successfully, session f95f1a4b-a507-4fbb-a745-68ee446823b7 added to master session list
[MJSONWP] Responding to client with driver.createSession() result: {"webStorageEnabled":false,...
[HTTP] <-- POST /wd/hub/session 200 12454 ms - 865 
[HTTP] --> POST /wd/hub/session/f95f1a4b-a507-4fbb-a745-68ee446823b7/timeouts/implicit_wait {"ms":0}
[MJSONWP] Calling AppiumDriver.implicitWait() with args: [0,"f95f1a4b-a507-4fbb-a745...
[debug] [iOS] Executing iOS command 'implicitWait'
[debug] [BaseDriver] Set implicit wait to 0ms
[MJSONWP] Responding to client with driver.implicitWait() result: null
[HTTP] <-- POST /wd/hub/session/f95f1a4b-a507-4fbb-a745-68ee446823b7/timeouts/implicit_wait 200 3 ms - 76 
[HTTP] --> DELETE /wd/hub/session/f95f1a4b-a507-4fbb-a745-68ee446823b7 {}
[MJSONWP] Calling AppiumDriver.deleteSession() with args: ["f95f1a4b-a507-4fbb-a745-6...
[debug] [iOS] Deleting ios session
[debug] [UIAuto] Destroying instruments client socket.
[debug] [UIAuto] Closing socket server.
[debug] [UIAuto] Instruments socket server was closed
[debug] [Instruments] Starting shutdown.
[debug] [Instruments] Sending sigterm to instruments
[debug] [Instruments] [INST] 2016-10-27 15:44:54 +0000 Stopped: Script was stopped by the user
[debug] [Instruments] [INST] 2016-10-27 15:44:43 +0000 Debug: Running system command #3: /usr/local/Cellar/node/6.5.0/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-ios-driver/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js /var/folders/k0/s803_jl52hvggnvg9sbdbbf00000gn/T/instruments_sock 2,{"status":0,"value":{"UIAApplication":{"@":{"name":"Game...
[debug] [Instruments] [INST STDERR] 2016-10-27 13:44:54.148 instruments[48785:3326419] Attempting to change event horizon while disengage
[debug] [Instruments] [INST] Instruments Trace Complete (Duration : 16.225965s; Output : /var/folders/k0/s803_jl52hvggnvg9sbdbbf00000gn/T/appium-instruments/instrumentscli0.trace)
[debug] [Instruments] Instruments exited with code 0
[debug] [iOSLog] Stopping iOS log capture
[debug] [iOS] Running ios real device reset flow
[Appium] Removing session f95f1a4b-a507-4fbb-a745-68ee446823b7 from our master session list
[debug] [MJSONWP] Received response: null
[debug] [MJSONWP] But deleting session, so not returning
[MJSONWP] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /wd/hub/session/f95f1a4b-a507-4fbb-a745-68ee446823b7 200 374 ms - 76

Looks like appium doesnt allow parallel tests in iOS

https://appium.readthedocs.io/en/stable/en/appium-setup/parallel_tests/