<commit_before>functor
import
   Remote
   Connection
   Pickle
   System(show:Show)
export
   Return
define
   fun{CreateTest Config Check}
      proc{$}
          M={New Remote.manager Config}
      in
         {M apply(Check)}
         {Delay 2000}
         {M close}
      end
   end

   % Check that firewall option is false with no specific initialization
   Plain={CreateTest init functor
                          import
                             DPInit
                          define
                             {DPInit.getSettings}.firewall=false
                          end}

   FireWall={CreateTest init(firewall:true)
             functor
             import
                DPInit
             define
                {DPInit.getSettings}.firewall=true
             end}

   Port=proc{$}
           thread
              {{CreateTest init(port:10101) functor
                                            import
                                               DPInit
                                               Connection
                                               Pickle
                                               OS
                                            define
                                               {DPInit.getSettings}.port=10101
                                               {Pickle.save
                                                {Connection.offer {OS.getPID}}
                                                '/tmp/afd'}
                                            end}}
           end
           {Delay 1000}
           {Connection.take {Pickle.load '/tmp/afd'}}=_
        end

   LoopbackIp={CreateTest init(ip:"127.0.0.1")
               functor
               import
                  Remote
               define
                  M={New Remote.manager init}
               in
                  {M apply(functor
                           define
                              skip
                           end)}
                  {M close}
               end}

   Return = dp([init_settings_plain(Plain keys:[remote])
                init_settings_firewall(FireWall keys:[remote])
                init_settings_port(Port keys:[remote])
                init_settings_loopback_ip(LoopbackIp keys:[remote])
               ])
end<commit_msg>my mods to remove inappropriate delays and use proper synchronization instead.  This code is now thread safe (I think).  However there is no timeout to guard against blocking forever in case things should go wrong. This now works fine on the laptop even with --threads=5.<commit_after>functor
import
   Remote
   Connection
   Pickle
   System(show:Show)
   OS(tmpnam unlink)
export
   Return
define
   fun{CreateTest Config Check}
      proc{$}
          M={New Remote.manager Config}
      in
         {Wait {M apply(Check $)}}
         {M close}
      end
   end

   % Check that firewall option is false with no specific initialization
   Plain =
   {CreateTest init
    functor
    import
       DPInit
    define
       {DPInit.getSettings}.firewall=false
    end}

   FireWall =
   {CreateTest init(firewall:true)
    functor
    import
       DPInit
    define
       {DPInit.getSettings}.firewall=true
    end}

   Port =
   local
      C={NewCell 10101}
      fun {MakePortNumber} N1 N2 in
         {Exchange C N1 N2}
         N2 = 1+N1
         N1
      end
   in
      proc{$}
         TempFile = {OS.tmpnam}
         PortNum  = {MakePortNumber}
         Pid
      in
         try
            thread
               {{CreateTest init(port:PortNum)
                 functor
                 import
                    DPInit
                    Connection
                    Pickle
                    OS
                 define
                    {DPInit.getSettings}.port=PortNum
                    local N={OS.getPID} in
                       {Pickle.save {Connection.offer N} TempFile}
                       !Pid=N
                    end
                 end}}
            end
            {Wait Pid}
            {Connection.take {Pickle.load TempFile}}=Pid
         finally
            try {OS.unlink TempFile} catch _ then skip end
         end
      end
   end

   LoopbackIp =
   {CreateTest init(ip:"127.0.0.1")
    functor
    import
       Remote
    define
       M={New Remote.manager init}
    in
       {M apply(functor
                define
                   skip
                end)}
       {M close}
    end}

   Return = dp([init_settings_plain(Plain keys:[remote])
                init_settings_firewall(FireWall keys:[remote])
                init_settings_port(Port keys:[remote])
                init_settings_loopback_ip(LoopbackIp keys:[remote])
               ])
end
{'fraction_non_alphanumeric': 0.06117247238742566, 'fraction_numerical': 0.009345794392523364, 'mean_word_length': 1.0271201033146793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '106704', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1084, 'n_words': 293}